1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-15 02:11:07 +02:00

49211: _typeset: correctly set return value

do not include '-' in onopts so that 'functions -- <TAB>' works.
This commit is contained in:
Jun-ichi Takimoto 2021-07-30 01:10:24 +09:00
parent f8ec33c453
commit b4dff9a8e8
2 changed files with 19 additions and 14 deletions

View file

@ -1,3 +1,7 @@
2021-07-30 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 49211: Completion/Zsh/Command/_typeset: correctly set return value
2021-07-23 Peter Stephenson <p.w.stephenson@ntlworld.com> 2021-07-23 Peter Stephenson <p.w.stephenson@ntlworld.com>
* Erik Paulson: 49029: Src/signals.c: Remove additional copies * Erik Paulson: 49029: Src/signals.c: Remove additional copies

View file

@ -1,6 +1,6 @@
#compdef autoload declare export functions integer float local readonly typeset #compdef autoload declare export functions integer float local readonly typeset
local expl state line func i use curcontext="$curcontext" local expl state state_descr line func i use curcontext="$curcontext" ret=1
local fopts="-f -k -z +k +z" local fopts="-f -k -z +k +z"
local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x" local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x"
local -A allargs opt_args local -A allargs opt_args
@ -79,38 +79,38 @@ esac
# This function uses whacky features of _arguments which means we # This function uses whacky features of _arguments which means we
# need to look for options to the command beforehand. # need to look for options to the command beforehand.
local onopts offopts local onopts offopts
onopts=${(j..)${${words[1,CURRENT-1]:#^-*}##-}} onopts=${(j..)${${words[1,CURRENT-1]:#^-[^-]*}##-}}
offopts=${(j..)${${words[1,CURRENT-1]:#^+*}##+}} offopts=${(j..)${${words[1,CURRENT-1]:#^+*}##+}}
for ((i=1;i<=$#use;++i)); do for ((i=1;i<=$#use;++i)); do
args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[dUurRtT]]:+$func}]} ) args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[dUurRtT]]:+$func}]} )
done done
_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' _arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' && ret=0
if [[ "$state" = vars_eq ]]; then if [[ "$state" = vars_eq ]]; then
if [[ $func = f ]]; then if [[ $func = f ]]; then
if (( $+opt_args[+M] || ( $+opt_args[-M] && $+opt_args[-m] ) )); then if (( $+opt_args[+M] || ( $+opt_args[-M] && $+opt_args[-m] ) )); then
_wanted functions expl 'math function' compadd -F line - \ _wanted functions expl 'math function' compadd -F line - \
${${${(f)"$(functions -M)"}##*-M }%% *} ${${${(f)"$(functions -M)"}##*-M }%% *} && ret=0
elif (( $+opt_args[-M] )); then elif (( $+opt_args[-M] )); then
_arguments ':new math function:_functions' \ _arguments ':new math function:_functions' \
":minimum arguments${(k)opt_args[-s]:+:(1)}" \ ":minimum arguments${(k)opt_args[-s]:+:(1)}" \
":maximum arguments${(k)opt_args[-s]:+:(1)}" \ ":maximum arguments${(k)opt_args[-s]:+:(1)}" \
':shell function:_functions' ':shell function:_functions' && ret=0
elif (( $+opt_args[-w] )); then elif (( $+opt_args[-w] )); then
_wanted files expl 'zwc file' _files -g '*.zwc(-.)' _wanted files expl 'zwc file' _files -g '*.zwc(-.)' && ret=0
elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
if [[ $PREFIX[1] = [/~] ]]; then if [[ $PREFIX[1] = [/~] ]]; then
# Autoload by absolute path # Autoload by absolute path
_files _files && ret=0
else else
args=(${^fpath}/*(-.:t)) args=(${^fpath}/*(-.:t))
# Filter out functions already loaded or marked for autoload. # Filter out functions already loaded or marked for autoload.
local -a funckeys local -a funckeys
funckeys=(${(k)functions}) funckeys=(${(k)functions})
args=(${args:|funckeys}) args=(${args:|funckeys})
_wanted functions expl 'shell function' compadd -a args _wanted functions expl 'shell function' compadd -a args && ret=0
fi fi
elif [[ -n $onopts$offopts ]]; then elif [[ -n $onopts$offopts ]]; then
if [[ -n $offopts ]]; then if [[ -n $offopts ]]; then
@ -127,22 +127,23 @@ if [[ "$state" = vars_eq ]]; then
[[ $PREFIX != [_.]* ]]; then [[ $PREFIX != [_.]* ]]; then
args=(${args:#_*}) args=(${args:#_*})
fi fi
_wanted functions expl 'shell function' compadd -a args _wanted functions expl 'shell function' compadd -a args && ret=0
else else
_functions _functions && ret=0
fi fi
elif [[ "$PREFIX" = *\=* ]]; then elif [[ "$PREFIX" = *\=* ]]; then
compstate[parameter]="${PREFIX%%\=*}" compstate[parameter]="${PREFIX%%\=*}"
compset -P 1 '*=' compset -P 1 '*='
_value _value && ret=0
elif (( $+opt_args[-a] || $+opt_args[-A] )); then elif (( $+opt_args[-a] || $+opt_args[-A] )); then
_parameters -q _parameters -q && ret=0
elif (( $+opt_args[-T] )); then elif (( $+opt_args[-T] )); then
_arguments \ _arguments \
':scalar parameter:_parameters -g "*scalar*" -q -S "="' \ ':scalar parameter:_parameters -g "*scalar*" -q -S "="' \
':array parameter:_parameters -g "*array*"' \ ':array parameter:_parameters -g "*array*"' \
':separator character' ':separator character' && ret=0
else else
_parameters -q -S '=' _parameters -q -S '=' && ret=0
fi fi
fi fi
return ret