mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
22593: add handle-nonexistent style to MIME handler
This commit is contained in:
parent
901e6c7387
commit
5bfe4cb650
3 changed files with 35 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-08-09 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 22593: Doc/Zsh/contrib.yo, Functions/MIME/zsh-mime-handler: add
|
||||||
|
handle-nonexistent style.
|
||||||
|
|
||||||
2006-08-08 Peter Stephenson <pws@csr.com>
|
2006-08-08 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 22592: Functions/TCP/tcp_send, Doc/Zsh/tcpsys.yo: add tcp_send
|
* 22592: Functions/TCP/tcp_send, Doc/Zsh/tcpsys.yo: add tcp_send
|
||||||
|
|
|
@ -1432,6 +1432,15 @@ item(tt(flags))(
|
||||||
Defines flags to go with a handler; the context is as for the
|
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).
|
tt(handler) style, and the format is as for the flags in tt(mailcap).
|
||||||
)
|
)
|
||||||
|
item(tt(handle-nonexistent))(
|
||||||
|
By default, arguments that don't correspond to files are not passed
|
||||||
|
to the MIME handler in order to prevent it from intercepting commands found
|
||||||
|
in the path that happen to have suffixes. This style may be set to
|
||||||
|
an array of extended glob patterns for arguments that will be passed to the
|
||||||
|
handler even if they don't exist. If it is not explicitly set it
|
||||||
|
defaults to tt([[:alpha:]]:/*) which allows URLs to be passed to the MIME
|
||||||
|
handler even though they don't exist in that format in the file system.
|
||||||
|
)
|
||||||
item(tt(handler))(
|
item(tt(handler))(
|
||||||
Specifies a handler for a suffix; the suffix is given by the context as
|
Specifies a handler for a suffix; the suffix is given by the context as
|
||||||
tt(:mime:.)var(suffix)tt(:), and the format of the handler is exactly
|
tt(:mime:.)var(suffix)tt(:), and the format of the handler is exactly
|
||||||
|
|
|
@ -48,7 +48,7 @@ suffix=$match[1]
|
||||||
context=":mime:.${suffix}:"
|
context=":mime:.${suffix}:"
|
||||||
|
|
||||||
local handler flags no_sh no_bg
|
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,
|
# Set to a list of patterns which are ignored and executed as they are,
|
||||||
# despite being called for interpretation by the mime handler.
|
# 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.
|
# they are, even if they have a suffix.
|
||||||
zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)' '*(/)')
|
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 pattern
|
||||||
local -a files
|
local -a files
|
||||||
|
|
||||||
|
@ -74,10 +79,24 @@ for pattern in $exec_asis; do
|
||||||
files=(${dirpref}${~pattern})
|
files=(${dirpref}${~pattern})
|
||||||
if [[ -n ${files[(r)$1]} ]]; then
|
if [[ -n ${files[(r)$1]} ]]; then
|
||||||
"$@"
|
"$@"
|
||||||
return 0
|
return
|
||||||
fi
|
fi
|
||||||
done
|
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 ||
|
zstyle -s $context handler handler ||
|
||||||
handler="${zsh_mime_handlers[$suffix]}"
|
handler="${zsh_mime_handlers[$suffix]}"
|
||||||
zstyle -s $context flags flags ||
|
zstyle -s $context flags flags ||
|
||||||
|
|
Loading…
Reference in a new issue