zsh-workers
 help / color / mirror / code / Atom feed
From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: zsh-workers@zsh.org
Subject: [PATCH] Try dir if ls -lF isn't supported by server
Date: Tue, 26 May 2015 15:53:47 +0800	[thread overview]
Message-ID: <20150526075347.GA15120@localhost.localdomain> (raw)

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


                 reply	other threads:[~2015-05-26  7:53 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=20150526075347.GA15120@localhost.localdomain \
    --to=hanpt@linux.vnet.ibm.com \
    --cc=zsh-workers@zsh.org \
    /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).