summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-04-13 16:31:39 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-04-13 16:31:39 +0000
commit1bae764d5a483bf975a967f20086598fe3906b47 (patch)
tree1fdc45b2f97914e757b82120452621716a5f05ec
parent02e0363afac537a428acd616ee8124a475fddcdf (diff)
downloadzsh-1bae764d5a483bf975a967f20086598fe3906b47.tar.gz
zsh-1bae764d5a483bf975a967f20086598fe3906b47.tar.xz
zsh-1bae764d5a483bf975a967f20086598fe3906b47.zip
Check for parameter expansions before tilde-expansions (fixes bugs reported
in zsh-workers/13971).
-rw-r--r--Completion/Unix/Type/_path_files34
1 files changed, 17 insertions, 17 deletions
diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files
index 541a883e8..bc784426c 100644
--- a/Completion/Unix/Type/_path_files
+++ b/Completion/Unix/Type/_path_files
@@ -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.