about summary refs log tree commit diff
path: root/Functions/MIME
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-08-09 16:17:12 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-08-09 16:17:12 +0000
commit5bfe4cb650d71ed1e2345248793cd5ee96fb03b8 (patch)
tree37be79f50f5ba0fc56324002a70957636f860d32 /Functions/MIME
parent901e6c7387bd0145ce26356eda1573d20293a57a (diff)
downloadzsh-5bfe4cb650d71ed1e2345248793cd5ee96fb03b8.tar.gz
zsh-5bfe4cb650d71ed1e2345248793cd5ee96fb03b8.tar.xz
zsh-5bfe4cb650d71ed1e2345248793cd5ee96fb03b8.zip
22593: add handle-nonexistent style to MIME handler
Diffstat (limited to 'Functions/MIME')
-rw-r--r--Functions/MIME/zsh-mime-handler23
1 files changed, 21 insertions, 2 deletions
diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler
index 52be70618..83df242af 100644
--- a/Functions/MIME/zsh-mime-handler
+++ b/Functions/MIME/zsh-mime-handler
@@ -48,7 +48,7 @@ suffix=$match[1]
 context=":mime:.${suffix}:"
 
 local handler flags no_sh no_bg
-local -a exec_asis
+local -a exec_asis hand_nonex
 
 # Set to a list of patterns which are ignored and executed as they are,
 # despite being called for interpretation by the mime handler.
@@ -56,6 +56,11 @@ local -a exec_asis
 # they are, even if they have a suffix.
 zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)' '*(/)')
 
+# Set to a list of patterns for which the handler will be used even
+# if the file doesn't exist on the disk.
+zstyle -a $context handle-nonexistent hand_nonex ||
+  hand_nonex=('[[:alpha:]]#:/*')
+
 local pattern
 local -a files
 
@@ -74,10 +79,24 @@ for pattern in $exec_asis; do
   files=(${dirpref}${~pattern})
   if [[ -n ${files[(r)$1]} ]]; then
     "$@"
-    return 0
+    return
   fi
 done
 
+if [[ ! -e $1 ]]; then
+  local nonex_ok
+  for pattern in $hand_nonex; do
+    if [[ $1 = ${~pattern} ]]; then
+      nonex_ok=1
+      break
+    fi
+  done
+  if [[ -z $nonex_ok ]]; then
+    "$@"
+    return
+  fi
+fi
+
 zstyle -s $context handler handler ||
   handler="${zsh_mime_handlers[$suffix]}"
 zstyle -s $context flags flags ||