zsh-workers
 help / color / mirror / code / Atom feed
* [zftp] zfcd completion and FTP ls behavior
@ 2008-08-15 15:07 Stephane Chazelas
  0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2008-08-15 15:07 UTC (permalink / raw)
  To: Zsh hackers list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-08-15 15:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-15 15:07 [zftp] zfcd completion and FTP ls behavior Stephane Chazelas

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).