diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2018-11-03 19:36:06 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2018-11-03 19:36:06 +0000 |
commit | 916ba78cd7c30800e7025bb91e735e27320fff29 (patch) | |
tree | 32406a1a98550a25eff9a00dbe6c1645347efe7e /Completion/Base | |
parent | 58bfa1665ba344968c91509a3ac6242034384432 (diff) | |
download | zsh-916ba78cd7c30800e7025bb91e735e27320fff29.tar.gz zsh-916ba78cd7c30800e7025bb91e735e27320fff29.tar.xz zsh-916ba78cd7c30800e7025bb91e735e27320fff29.zip |
43752: Fix _expand quoting.
Quoting was not applied properly if globbing failed or was not applied.
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/Completer/_expand | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand index ee3681bad..f4909826a 100644 --- a/Completion/Base/Completer/_expand +++ b/Completion/Base/Completer/_expand @@ -103,9 +103,19 @@ subd=("$exp[@]") # Now try globbing. -[[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob && - eval 'exp=( ${~exp//(#b)\\([ \"'"\'"' +# We need to come out of this with consistent quoting, by hook or by crook. +integer done_quote +local orig_exp=$exp +if [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob; then + eval 'exp=( ${~exp//(#b)\\([ \"'"\'"' +])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null && done_quote=1 +fi +# If the globbing failed, or we didn't try globbing, we'll do +# it again without the "~" so globbing is simply omitted. +if (( ! done_quote )); then + eval 'exp=( ${orig_exp//(#b)\\([ \"'"\'"' ])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null +fi ### Don't remember why we once used this instead of the (q) above. # eval 'exp=( ${~exp} ); exp=( ${exp//(#b)([][()|*?^#~<>\\=])/\\${match[1]}} )' 2>/dev/null |