From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21508 invoked by alias); 11 Mar 2017 05:20:08 -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: 40829 Received: (qmail 16643 invoked from network); 11 Mar 2017 05:20:08 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk0-f65.google.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(209.85.213.65):SA:0(0.5/5.0):. Processed in 0.761123 secs); 11 Mar 2017 05:20:08 -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.5 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,SPF_PASS, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.213.65 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=R906HKlVN+c+9pxqm05gBuvwKYCGG+0+ZoB/De+B5+c=; b=qzy7bBIyu45yzI0raw9EGIHOZL7vIMI60VZGKfrrWrQckZf/CSFTraGgzahk7V7OE2 PvtyqinS7UGdArijmioacdVntAVCp3lMdQt4MDQpxpoXiJJ74wdWtfnnB6nOK+0wj5US Bl+z11rkXmSosu3gP9Eli8bCE9HQaBu7Zgt916vhhnjzTXHBNENnc5iJurmx+aR8NAi2 O/R0tdXPNafkcayej71tBZBq35dGijCcURkuLIk5J1BCOxIwDltwCP8V800EGB7D/G7u rv5qkL/dDBCCPacGXYPfMBImDt8nwR95PYtc+xoPzTcjkEP7S5OYhkJOSA04llI3Az3x dGTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=R906HKlVN+c+9pxqm05gBuvwKYCGG+0+ZoB/De+B5+c=; b=Plvj6GViQXhCy9I7IXk/ZFSALXzhxUU1mpXW/zS85ZRGLKm2ElosEp6cmsOAmc0uwd RzjEjRH6hEw5EFF+M/OH+5U/S7P+bmTofep5Bv46hPzE7/4rd4KIN7Mfh/oAi8HL30v2 5Ah197MP4w7lBFhmhHHuT79qGYUKjp25WHNB0LzI2QSmjGKaix8dM/ISqkscA/Xsm+Ng PufLDKpHtF57UaWtfSB9iuUfnfkQqccxJAgUYUjgbYy/vONSmM8aMIBo7AuCrYH484oA ZS7W8z6D3Yf9QFZUb0Br8STCsEax69UMYOmf5/ptIh7JGvXJqrJ5tM71NJ8Ou73opE4M 0XlQ== X-Gm-Message-State: AMke39neC2FTXZHi+ftZG75AnSmRD/hYoCn8ItruiwmbQzJXlBfFycJ7bYUI56MkrRdWOw== X-Received: by 10.31.216.5 with SMTP id p5mr8996164vkg.170.1489209601041; Fri, 10 Mar 2017 21:20:01 -0800 (PST) From: Bart Schaefer Message-Id: <170310212034.ZM18289@torch.brasslantern.com> Date: Fri, 10 Mar 2017 21:20:34 -0800 In-Reply-To: <170310183110.ZM17610@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: [bug] escaping spaces in _canonical_paths" (Mar 10, 6:31pm) References: <87a88yk32i.fsf@mure.haselwarter.org> <170309214820.ZM30638@torch.brasslantern.com> <20170310055342.GB4113@fujitsu.shahaf.local2> <170310183110.ZM17610@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: [bug] escaping spaces in _canonical_paths MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 10, 6:31pm, Bart Schaefer wrote: } } There [is] a bug with the :P modifier -- see other thread. With that } fixed, things are better, but still messed up when $compstate[quote] is } a substring of the mount point name (if you see what I mean). OK, the following is getting very close. Ignore previous patch (40811). Even with this, there are some oddities. For example because "/" is normally a mount point, if "/" is the current directory the relative path '' (empty string) is offered as a completion. For another, I've discovered that if you have a quote in the directory name like my previous example: % sudo umount mnt/aa\' nothing completes, because $PREFIX is actually incorrect at this point; it has the value mnt/aa\'\' (an extra escaped quote at the end) so it can never be correctly suffixed. I don't know if this is a bug in the completion internals or if _mount somehow messes it up before the call to _canonical_paths is made. Fascinatingly, % sudo umount mnt/aa\ % sudo umount mnt/aa\''cc 2' correctly completes. I also found one case where I managed to get a trailing space (as if for auto-removal) to appear inside the quotes, but I can't reproduce now. Still, the number of cases this gets right is larger than for the previous code, I think. Someone will probably find a previously- working case that this breaks. diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths index 6eab7b6..9ec7376 100644 --- a/Completion/Unix/Type/_canonical_paths +++ b/Completion/Unix/Type/_canonical_paths @@ -41,7 +41,16 @@ _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}) + origpref=${(Q)origpref} + local canpat=${(b)${(Q)canpref}} + case $compstate[quote] in + (\') + matches+=(${${${(M)files:#$canpref*}/$canpat/$origpref}//\'/\'\\\'\'});; + (\") + matches+=(${${${(M)files:#$canpref*}/$canpat/$origpref}//\"/\\\"});; + (*) + matches+=(${(q-)${(M)files:#$canpref*}/$canpat/$origpref});; + esac fi for subdir in $expref?*(@); do