From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3595 invoked from network); 15 Aug 2008 15:07:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Aug 2008 15:07:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 36466 invoked from network); 15 Aug 2008 15:07:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Aug 2008 15:07:26 -0000 Received: (qmail 3382 invoked by alias); 15 Aug 2008 15:07:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25453 Received: (qmail 3364 invoked from network); 15 Aug 2008 15:07:11 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 15 Aug 2008 15:07:11 -0000 Received: from mail.o2.co.uk (jabba.london.02.net [82.132.130.169]) by bifrost.dotsrc.org (Postfix) with ESMTP id 4AD8080EA0B3 for ; Fri, 15 Aug 2008 17:07:07 +0200 (CEST) Received: from sc.homeunix.net (78.105.216.138) by mail.o2.co.uk (8.0.013.3) (authenticated as stephane.chazelas) id 48A249000082B9E6 for zsh-workers@sunsite.dk; Fri, 15 Aug 2008 17:24:58 +0100 Received: from chazelas by sc.homeunix.net with local (Exim 4.69) (envelope-from ) id 1KU0tM-0000nm-3x for zsh-workers@sunsite.dk; Fri, 15 Aug 2008 16:07:04 +0100 Date: Fri, 15 Aug 2008 16:07:03 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: [zftp] zfcd completion and FTP ls behavior Message-ID: <20080815150703.GB5278@sc.homeunix.net> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.16 (2007-09-19) X-Virus-Scanned: ClamAV 0.92.1/8048/Fri Aug 15 14:56:27 2008 on bifrost X-Virus-Status: Clean 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