From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14454 invoked by alias); 23 Nov 2011 00:54:12 -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: 29912 Received: (qmail 24642 invoked from network); 23 Nov 2011 00:54:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at qult.net does not designate permitted sender hosts) Date: Wed, 23 Nov 2011 01:21:50 +0100 From: Ignacy =?iso-8859-2?Q?Gaw=EAdzki?= To: zsh-workers@zsh.org Subject: File completion of scp (tentative fix) Message-ID: <20111123002149.GA9025@zenon.in.qult.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, It's been some time since I wanted to track this bug down and finally took the time to do it. Supposing you have a remote host with a file in the home directory that begins with a dash, the completion may fail because the file argument is interpreted by ls as an option. See the attached patch, which adds a -- before the pattern, so that files starting with a dash won't possibly be considered as options. This is the way to go with a GNU ls on the other side, but I don't know how other versions will interpret that. Maybe something more sophisticated has to be done to remain as generic as possible. -- Save the whales. Feed the hungry. Free the mallocs. --k1lZvvs/B4yU6o8G Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="zsh-scp-completion.patch" diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index d0944c6..0ec9c84 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -16,7 +16,7 @@ _remote_files () { then rempat="${PREFIX%%[^./][^/]#}\*" else rempat="${(q)PREFIX%%[^./][^/]#}\*" fi - remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) + remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) compset -P '*/' compset -S '/*' || suf='remote file' --k1lZvvs/B4yU6o8G--