1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 04:40:59 +01:00

22394, 22043: execute-as-is style for MIME suffixes

This commit is contained in:
Peter Stephenson 2006-04-05 10:26:30 +00:00
parent fd92cf5686
commit 2930828678
3 changed files with 29 additions and 0 deletions

View file

@ -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.

View file

@ -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).

View file

@ -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]}"