From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28064 invoked from network); 29 Feb 2008 20:22:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) 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.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 29 Feb 2008 20:22:11 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 52726 invoked from network); 29 Feb 2008 20:22:06 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Feb 2008 20:22:06 -0000 Received: (qmail 29707 invoked by alias); 29 Feb 2008 20:22:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24635 Received: (qmail 29673 invoked from network); 29 Feb 2008 20:22:00 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 29 Feb 2008 20:22:00 -0000 Received: from acolyte.scowler.net (acolyte.scowler.net [216.254.112.45]) by bifrost.dotsrc.org (Postfix) with ESMTP id 5437A8026E0B for ; Fri, 29 Feb 2008 21:21:52 +0100 (CET) Received: by acolyte.scowler.net (Postfix, from userid 1000) id 7B5D65C1A4; Fri, 29 Feb 2008 15:21:50 -0500 (EST) Date: Fri, 29 Feb 2008 15:21:50 -0500 From: Clint Adams To: zsh-workers@sunsite.dk Cc: Adrian Irving-Beer , 468654@bugs.debian.org Subject: Re: Bug#468654: zsh: rsync completion fails to complete remote paths with spaces Message-ID: <20080229202150.GA18766@scowler.net> Mail-Followup-To: zsh-workers@sunsite.dk, Adrian Irving-Beer , 468654@bugs.debian.org References: <20080229200414.GA3027@wisq.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080229200414.GA3027@wisq.net> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Virus-Scanned: ClamAV 0.91.2/6047/Fri Feb 29 19:51:13 2008 on bifrost X-Virus-Status: Clean On Fri, Feb 29, 2008 at 03:04:14PM -0500, Adrian Irving-Beer wrote: > If I have the following on host 'alpha': > > /tmp/foo bar baz/foo > /tmp/foo bar baz/bar > /tmp/foo bar baz/baz > > I can do this: > > % rsync alpha:/tmp/foo > --> % rsync alpha:/tmp/foo\\\ bar\\\ baz/ > > But I can't continue: > > % rsync alpha:/tmp/foo\\\ bar\\\ baz/ > --> no response > > Tracing this, I found that it ran a failing 'ls' via ssh, something akin > to this: > > ssh -a -x alpha ls -d1FL "/tmp/foo bar baz/*" > > This fails because the quoting only makes the argument appear as a > single argument to 'ssh'; when ssh passes the command to the remote > host, it comes out as trying to list three different files. > > The solution is to double-quote the parameter, akin to this: > > ssh -a -x alpha ls -d1FL "\"/tmp/foo bar baz/\"*" > > I've attached a patch. I'm no zsh expert, so it needs review -- I > don't know if I've fixed one thing and broken another. But it does > seem to work for this situation. > > --- /usr/share/zsh/functions/Completion/Unix/_rsync 2008-02-28 00:39:09.000000000 -0500 > +++ /usr/share/zsh-beta/functions/Completion/Unix/_rsync 2008-02-29 14:46:52.000000000 -0500 > @@ -58,7 +58,7 @@ > elif compset -P 1 '*:'; then > > if zstyle -T ":completion:${curcontext}:files" remote-access; then > - remfiles=(${(M)${(f)"$(_call_program files ssh -a -x ${IPREFIX%:} ls -d1FL "${(Q)PREFIX%%[^./][^/]#}\*" 2>/dev/null)"}%%[^/]#(|/)}) > + remfiles=(${(M)${(f)"$(_call_program files ssh -a -x ${IPREFIX%:} ls -d1FL "\"${(Q)PREFIX%%[^./][^/]#}\"\*" 2>/dev/null)"}%%[^/]#(|/)}) > compset -P '*/' > compset -S '/*' || suf='remote file' Maybe _rsync should get the same QIPREFIX check as _ssh and _git, or maybe all three of these should be factored out into a helper function.