From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6500 invoked by alias); 26 May 2015 07:53:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35295 Received: (qmail 5062 invoked from network); 26 May 2015 07:53:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 Date: Tue, 26 May 2015 15:53:47 +0800 From: Han Pingtian To: zsh-workers@zsh.org Subject: [PATCH] Try dir if ls -lF isn't supported by server Message-ID: <20150526075347.GA15120@localhost.localdomain> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15052607-0057-0000-0000-0000003FA40E This patch try to fix two problems: 1. on some ftp server, "ls -lF" cann't show long listing format of files, but "dir" can. 2. can be used with directories which have spaces in name --- Functions/Zftp/zfcd_match | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Functions/Zftp/zfcd_match b/Functions/Zftp/zfcd_match index 9159f49..d977983 100644 --- a/Functions/Zftp/zfcd_match +++ b/Functions/Zftp/zfcd_match @@ -25,7 +25,13 @@ if [[ $ZFTP_SYSTEM = UNIX* ]]; then fi # If we're using -F, we get away with using a directory # to list, but not a glob. Don't ask me why. - reply=(${${(M)${(f)"$(zftp ls -lF $dir)"}:#d*}/(#b)*[[:space:]](*)\//$match[1]}) + reply=(${(M)${(f)"$(zftp ls -lF $dir)"}:#d([^[:space:]]##[[:space:]]##)(#c8)?##\/}) + + # If ls -lF doesn't work, try dir ... + if ! (($#reply)); then + reply=(${(M)${(f)"$(zftp dir $dir)"}:#d([^[:space:]]##[[:space:]]##)(#c8)?##}) + fi + reply=(${reply/(#b)d([^[:space:]]##[[:space:]]##)(#c8)([^\/]##)\/#/$match[2]}) # () { # zftp ls -LF $dir >|$1 # reply=($(awk '/\/$/ { print substr($1, 1, length($1)-1) }' $1)) -- 1.9.3