about summary refs log tree commit diff
path: root/Functions/MIME
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-04-06 13:11:27 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-04-06 13:11:27 +0000
commit9c60453969b1be1c2d1011420a8e354c672c0f38 (patch)
treeecaa58419e0c45d01a0e6a894429c8af87ec1f44 /Functions/MIME
parent87660ee4c8d49eda269ae3ecd1c3b616f91aec79 (diff)
downloadzsh-9c60453969b1be1c2d1011420a8e354c672c0f38.tar.gz
zsh-9c60453969b1be1c2d1011420a8e354c672c0f38.tar.xz
zsh-9c60453969b1be1c2d1011420a8e354c672c0f38.zip
tweak pattern matching for execute-as-is
Diffstat (limited to 'Functions/MIME')
-rw-r--r--Functions/MIME/zsh-mime-handler21
1 files changed, 17 insertions, 4 deletions
diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler
index ab0c27fb0..34082011e 100644
--- a/Functions/MIME/zsh-mime-handler
+++ b/Functions/MIME/zsh-mime-handler
@@ -54,12 +54,25 @@ local -a exec_asis
 zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)')
 
 local pattern
+local -a files
+
+# In case the pattern contains glob qualifiers, as it does by default,
+# we need to do real globbing, not just pattern matching.
+# The strategy is to glob the files in the directory using the
+# pattern and see if the one we've been passed is in the list.
+local dirpref=${1%/*}
+if [[ $dirpref = $1 ]]; then
+  dirpref=
+else
+  dirpref+=/
+fi
 
 for pattern in $exec_asis; do
-    if [[ $1 = ${~pattern} ]]; then
-	"$@"
-	return 0
-    fi
+  files=(${dirpref}${~pattern})
+  if [[ -n ${files[(r)$1]} ]]; then
+    "$@"
+    return 0
+  fi
 done
 
 zstyle -s $context handler handler ||