1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-23 04:30:24 +02:00

26973: zmathfuncdef enhancements

This commit is contained in:
Peter Stephenson 2009-05-19 15:33:24 +00:00
parent cac27544ff
commit ad3d514ac7
2 changed files with 25 additions and 4 deletions

View file

@ -5,18 +5,34 @@
emulate -L zsh
setopt extendedglob
local -a match mbegin mend line
local func
if (( $# < 1 || $# > 2 )); then
print "Usage: $0 name [body]" >&2
if (( $# > 2 )); then
print "Usage: $0 [name [body]]" >&2
return 1
fi
zmodload -i zsh/parameter || return 1
if (( $# == 0 )); then
functions -M | while read -A line; do
func=${functions[$line[6]]}
if [[ $func = (#b)[[:space:]]#\(\([[:space:]]#(*[^[:space:]])[[:space:]]#\)\) ]]; then
print "zmathfuncdef $line[3] ${(qq)match[1]}"
fi
done
return 0
fi
local mname=$1
local fname="zsh_math_func_$1"
if (( $# == 1 )); then
functions +M $mname && unfunction $fname
return 0
elif [[ -n $functions[$fname] ]]; then
functions +M $mname
fi
integer iarg=0 ioptarg