summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Doc/Zsh/contrib.yo9
-rw-r--r--Functions/MIME/zsh-mime-handler16
3 files changed, 29 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 27d098e68..0774c683b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2006-04-05  Peter Stephenson  <pws@csr.com>
 
+	* 22394, R. Ramkumar, plus doc as 22043:
+	Functions/MIME/zsh-mime-handler, Doc/Zsh/contrib.yo:
+	execute-as-is style for MIME suffixes.
+
 	* 22393, R. Ramkumar, plus doc, 22402:
 	Completion/Unix/Type/_hosts, Doc/Zsh/compsys.yo: use-ip and
 	known-hosts-files styles.
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index bf83a69e2..a0fc1ff56 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1391,6 +1391,15 @@ question is run using the tt(eval) builtin instead of by starting a new
 tt(sh) process.  This is more efficient, but may not work in the occasional
 cases where the mailcap handler uses strict POSIX syntax.
 )
+item(tt(execute-as-is))(
+This style gives a list of patterns to be matched against files
+passed for execution with a handler program.  If the file matches
+the pattern, the entire command line is executed in its current form,
+with no handler.  This is useful for files which might have suffixes
+but nonetheless be executable in their own right.  If the style
+is not set, the pattern tt(*+LPAR()*+RPAR()) is used; hence executable
+files are executed directly and not passed to a handler.
+)
 item(tt(flags))(
 Defines flags to go with a handler; the context is as for the
 tt(handler) style, and the format is as for the flags in tt(mailcap).
diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler
index b8c6b6925..ab0c27fb0 100644
--- a/Functions/MIME/zsh-mime-handler
+++ b/Functions/MIME/zsh-mime-handler
@@ -45,6 +45,22 @@ suffix=$match[1]
 context=":mime:.${suffix}:"
 
 local handler flags no_sh no_bg
+local -a exec_asis
+
+# Set to a list of patterns which are ignored and executed as they are,
+# despite being called for interpretation by the mime handler.
+# Defaults to executable files, which ensures that they are executed as
+# they are, even if they have a suffix.
+zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)')
+
+local pattern
+
+for pattern in $exec_asis; do
+    if [[ $1 = ${~pattern} ]]; then
+	"$@"
+	return 0
+    fi
+done
 
 zstyle -s $context handler handler ||
   handler="${zsh_mime_handlers[$suffix]}"