zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: [zftp] zfcd completion and FTP ls behavior
Date: Fri, 15 Aug 2008 16:07:03 +0100	[thread overview]
Message-ID: <20080815150703.GB5278@sc.homeunix.net> (raw)

Hiya,

A FTP site (ftpperso.free.fr) outputs a ls -l type long listing
upon the "ls" FTP command.

So this code in zfcd_match:

  # If we're using -F, we get away with using a directory
  # to list, but not a glob.  Don't ask me why.
  # I hate having to rely on awk here.
  zftp ls -LF $dir >$tmpf
  reply=($(awk '/\/$/ { print substr($1, 1, length($1)-1) }' $tmpf))
  rm -f $tmpf

returns the "drwxr-xr-"s instead of the directory names.

Also, why using a tmpfile? Why awk? Why $1?

Is the tempfile to avoid the fork so that because zftp ls
updates a cache?

On that particular FTP server, using ls -1LF fixes it except for
filenames with blanks.

So:

reply=(${(f)"$(zftp ls -1LF $dir | sed -n 's|\(.*\)/$|\1|p')"})

would do.

or:

reply=(${${(M)${(f)"$(zftp ls -1LF $dir)"}#*/}%/})

Or with a temp file:

local tmpf==(:)
zftp ls -1LF $dir > $tmpf
reply=(${(f)"$(sed -n 's|\(.*\)/$|\1|p' < $tmp)"})
rm -f $tmpf

There's a similar problem in zfget_match.

-- 
Stéphane


                 reply	other threads:[~2008-08-15 15:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080815150703.GB5278@sc.homeunix.net \
    --to=stephane_chazelas@yahoo.fr \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).