mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-02-24 11:51:19 +01:00
Check for parameter expansions before tilde-expansions (fixes bugs reported
in zsh-workers/13971).
This commit is contained in:
parent
02e0363afa
commit
1bae764d5a
1 changed files with 17 additions and 17 deletions
|
@ -190,7 +190,23 @@ eorig="$orig"
|
|||
|
||||
# Now let's have a closer look at the string to complete.
|
||||
|
||||
if [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
|
||||
if [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then
|
||||
|
||||
# If there is a parameter expansion in the word from the line, we try
|
||||
# to complete the beast by expanding the prefix and completing anything
|
||||
# after the first slash after the parameter expansion.
|
||||
# This fails for things like `f/$foo/b/<TAB>' where the first `f' is
|
||||
# meant as a partial path.
|
||||
|
||||
linepath="${(M)pre##*\$[^/]##/}"
|
||||
eval 'realpath=${(e)~linepath}' 2>/dev/null
|
||||
[[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
|
||||
pre="${pre#${linepath}}"
|
||||
i="${#linepath//[^\\/]}"
|
||||
orig="${orig[1,(in:i:)/][1,-2]}"
|
||||
donepath=
|
||||
prepaths=( '' )
|
||||
elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
|
||||
# It begins with `~', so remember anything before the first slash to be able
|
||||
# to report it to the completion code. Also get an expanded version of it
|
||||
# (in `realpath'), so that we can generate the matches. Then remove that
|
||||
|
@ -241,22 +257,6 @@ if [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then
|
|||
orig="${orig#*/}"
|
||||
donepath=
|
||||
prepaths=( '' )
|
||||
elif [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then
|
||||
|
||||
# If there is a parameter expansion in the word from the line, we try
|
||||
# to complete the beast by expanding the prefix and completing anything
|
||||
# after the first slash after the parameter expansion.
|
||||
# This fails for things like `f/$foo/b/<TAB>' where the first `f' is
|
||||
# meant as a partial path.
|
||||
|
||||
linepath="${(M)pre##*\$[^/]##/}"
|
||||
eval 'realpath=${(e)~linepath}' 2>/dev/null
|
||||
[[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1
|
||||
pre="${pre#${linepath}}"
|
||||
i="${#linepath//[^\\/]}"
|
||||
orig="${orig[1,(in:i:)/][1,-2]}"
|
||||
donepath=
|
||||
prepaths=( '' )
|
||||
else
|
||||
# If the string does not start with a `~' we don't remove a prefix from the
|
||||
# string.
|
||||
|
|
Loading…
Reference in a new issue