Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Non-escaped special chars from var expansion



I've discovered that the prior fix for the following issue is actually
incomplete:

On Fri, Nov 2, 2018 at 1:39 PM Wayne Davison <wayne@xxxxxxxxxxxxx> wrote:

> zsh -f
> autoload -Uz compinit
> compinit
> zstyle ':completion:*' completer _oldlist _expand _complete _match
> _ignored _files _prefix
> zstyle ':completion:*:expand:*' tag-order all-expansions
> bindkey -e
> bindkey '\t' complete-word
> mkdir 'foo; bar (baz)'
> cd !:1
> cd $PWD<tab>
>

The fix works for this particular case because the attempted glob with
"(baz)" generated an error. However, I've found 2 cases that don't generate
an error where the non-glob code needs to be run, but it doesn't happen
because "done_quote=1" got set.  For instance, if you just run the test
from one level deeper in that weird directory:

    mkdir foo ; cd foo ; ls $PWD<tab>

That will expand to just "ls /tmp/foo;\ bar\ (baz)/foo" (the same bad
quoting as before). Alternatively, if we name the dir with some valid glob
suffix, it also fails to quote:

    mkdir '/tmp/foo (#qN)'
    cd !:1
    ls $PWD<tab>

In both failure cases I saw that $exp was an empty string, so I tweaked the
"&& done_quote=1" part of the code (in _expand) to be "&& [[ "$exp" ]] &&
done_quote=1" and this has fixed the quoting issues I was seeing.  I'm not
sure if it is the right fix, though.

..wayne..


Messages sorted by: Reverse Date, Date, Thread, Author