about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-06 11:36:33 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-06 11:36:33 +0000
commit9cb71e2f7cc2809b7d41e9160188ffe8af9e3b7d (patch)
treefd66df74fa7361246ff076428f2aec7cd198b339 /Completion/Core
parent4d08f8def21a24afb3b0a52dc11518a45e0ca2ab (diff)
downloadzsh-9cb71e2f7cc2809b7d41e9160188ffe8af9e3b7d.tar.gz
zsh-9cb71e2f7cc2809b7d41e9160188ffe8af9e3b7d.tar.xz
zsh-9cb71e2f7cc2809b7d41e9160188ffe8af9e3b7d.zip
tag in file-patterns optional, use `files' as default (10542)
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_files25
1 files changed, 16 insertions, 9 deletions
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 0c0231cb4..7a4fdc3a0 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -1,6 +1,6 @@
 #autoload
 
-local opts tmp glob pats expl tag i pat descr end ign ret=1
+local opts tmp glob pat pats expl tag i def descr end ign ret=1
 
 zparseopts -a opts \
     '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
@@ -19,9 +19,16 @@ else
   ign=
 fi
 
-if zstyle -a ":completion:${curcontext}:" file-patterns pats; then
+if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
   [[ "$type" = */* ]] && glob="$glob *(-/)"
-  pats=( \ ${(M)^${pats//\\%p/ ${glob:-\*} }:#*[^\\]:*} )
+  pats=()
+  for i in ${tmp//\\%p/ ${${glob:-\*}//:/\\:} }; do
+    if [[ $i = *[^\\]:* ]]; then
+      pats=( "$pats[@]" " $i" )
+    else
+      pats=( "$pats[@]" " ${i}:files" )
+    fi
+  done
 else
   if [[ "$type" = *g* ]]; then
     if [[ "$type" = */* ]]; then
@@ -37,14 +44,14 @@ else
   fi
 fi
 
-for tag in "${(@)${(@)pats#*[^\\]:}%%:*}"; do
+for def in "$pats[@]"; do ###"${(@)${(@)pats#*[^\\]:}%%:*}"; do
 
-  i="$pats[(I)*[^\\\\]:${tag}(|:*)]"
-  pat="${${pats[i]%%:${tag}*}//\\\\:/:}"
+  tag="${${def#*[^\\]:}%%:*}"
+  pat="${${def%%:${tag}*}//\\\\:/:}"
 
-  if [[ i -gt 0 && "$pat" != \ # ]]; then
-    if [[ "$pats[i]" = *:${tag}:* ]]; then
-      descr="${pats[i]#*:${tag}:}"
+  if [[ "$pat" != \ # ]]; then
+    if [[ "$def" = *:${tag}:* ]]; then
+      descr="${def#*:${tag}:}"
     else
       descr=file
       end=yes