From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1079 invoked by alias); 10 Mar 2017 05:58:34 -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: 40813 Received: (qmail 1877 invoked from network); 10 Mar 2017 05:58:34 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 1.133216 secs); 10 Mar 2017 05:58:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=vhmOsgF1XTSR05w uoQq6oT2Q8/M=; b=LTso8uybL55/KgGjvk2O/1qSWhu6U3z0W6zpo61MvNQG4G8 CrnOiy7oXZOhcrauelz1AfOWBSXvOkTebuRAF1cpjH4mvepOTsnWHvjw98dTyadS RqdfDo2VF82P5S/mk51T8dqoF247+BoqncSLiO1zwiIXlYIFJG7zv+zu3q4c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=vhmOsgF1XTSR05 wuoQq6oT2Q8/M=; b=XmCQbsVTUDMBlmAWpafgPQNcp37G+BZev59zpys94qzJZe BHHZbbz7hehsPqYHo8eQLlc49FqU+WcrB01/pz3j11Cj4hoihqiZ4lJ4KfAyjO8R WfM3Ft3GqJhPpQQfrkfDZa55Q8rx72MXFZGmyCcnj55A/Sej4SkV5L9jr95Xs= X-ME-Sender: X-Sasl-enc: AqVqO6T0hFAX+2VdtIL7wddQbX8fCutF/FDB3QxSTSH6 1489125510 Date: Fri, 10 Mar 2017 05:53:42 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: [bug] escaping spaces in _canonical_paths Message-ID: <20170310055342.GB4113@fujitsu.shahaf.local2> References: <87a88yk32i.fsf@mure.haselwarter.org> <170309214820.ZM30638@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <170309214820.ZM30638@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) Bart Schaefer wrote on Thu, Mar 09, 2017 at 21:48:20 -0800: > On Mar 6, 10:16am, Philipp G. Haselwarter wrote: > } > } however, if I cd into /mnt and then try to umount the relative path > } > } # cd /mnt > } # umount nam > } > } it gets completed to > } > } # umount name with spaces > } > } with no escapes for the spaces. > > This seems to do it, although I haven't figured out why it is necessary > to do the quote manipulation in the shell code here when it is not needed > in the other (absolute-path) branch. Perhaps the abspath branch gets confused on mountpoint names that contain literal ' characters? Since the ${foo/bar/baz} replacement is done on the compadd results, and compadd wasn't called with -Q. (Can't test this right now) > diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths > index 6eab7b6..630907b 100644 > --- a/Completion/Unix/Type/_canonical_paths > +++ b/Completion/Unix/Type/_canonical_paths > @@ -41,7 +41,11 @@ _canonical_paths_add_paths () { > # ### Ideally, this codepath would do what the 'if' above does, > # ### but telling compadd to pretend the "word on the command line" > # ### is ${"the word on the command line"/$origpref/$canpref}. > - matches+=(${${(M)files:#$canpref*}/$canpref/$origpref}) > + if [[ -z $compstate[quote] ]]; then > + matches+=(${(q)${(M)files:#$canpref*}/$canpref/$origpref}) > + else > + matches+=(${${(M)files:#$canpref*}/$canpref/$origpref}) > + fi > fi > > for subdir in $expref?*(@); do > @@ -84,7 +88,7 @@ _canonical_paths() { > files+=($@:P) > fi > > - local base=$PREFIX > + local base=${(Q)PREFIX} > typeset -i blimit > > _canonical_paths_add_paths $base