mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
tweak pattern matching for execute-as-is
This commit is contained in:
parent
87660ee4c8
commit
9c60453969
2 changed files with 22 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-04-06 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 22405: Functions/MIME/zsh-mime-handler: pattern matching
|
||||||
|
in 22394 needed tweaking.
|
||||||
|
|
||||||
2006-04-05 Clint Adams <clint@zsh.org>
|
2006-04-05 Clint Adams <clint@zsh.org>
|
||||||
|
|
||||||
* 22404: Completion/Unix/Command/_cowsay:
|
* 22404: Completion/Unix/Command/_cowsay:
|
||||||
|
|
|
@ -54,12 +54,25 @@ local -a exec_asis
|
||||||
zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)')
|
zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)')
|
||||||
|
|
||||||
local pattern
|
local pattern
|
||||||
|
local -a files
|
||||||
|
|
||||||
|
# In case the pattern contains glob qualifiers, as it does by default,
|
||||||
|
# we need to do real globbing, not just pattern matching.
|
||||||
|
# The strategy is to glob the files in the directory using the
|
||||||
|
# pattern and see if the one we've been passed is in the list.
|
||||||
|
local dirpref=${1%/*}
|
||||||
|
if [[ $dirpref = $1 ]]; then
|
||||||
|
dirpref=
|
||||||
|
else
|
||||||
|
dirpref+=/
|
||||||
|
fi
|
||||||
|
|
||||||
for pattern in $exec_asis; do
|
for pattern in $exec_asis; do
|
||||||
if [[ $1 = ${~pattern} ]]; then
|
files=(${dirpref}${~pattern})
|
||||||
"$@"
|
if [[ -n ${files[(r)$1]} ]]; then
|
||||||
return 0
|
"$@"
|
||||||
fi
|
return 0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
zstyle -s $context handler handler ||
|
zstyle -s $context handler handler ||
|
||||||
|
|
Loading…
Reference in a new issue