Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[zftp] zfcd completion and FTP ls behavior



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



Messages sorted by: Reverse Date, Date, Thread, Author