Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] escaping spaces in _canonical_paths
- X-seq: zsh-workers 40829
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [bug] escaping spaces in _canonical_paths
- Date: Fri, 10 Mar 2017 21:20:34 -0800
- 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==
- In-reply-to: <170310183110.ZM17610@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <87a88yk32i.fsf@mure.haselwarter.org> <170309214820.ZM30638@torch.brasslantern.com> <20170310055342.GB4113@fujitsu.shahaf.local2> <170310183110.ZM17610@torch.brasslantern.com>
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\'<TAB>
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\<TAB>
% 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author