1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-22 16:20:23 +02:00

22593: add handle-nonexistent style to MIME handler

This commit is contained in:
Peter Stephenson 2006-08-09 16:17:12 +00:00
parent 901e6c7387
commit 5bfe4cb650
3 changed files with 35 additions and 2 deletions

View file

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