mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-05 11:01:13 +02:00
unposted: _pick_variant: Use ${(P) ::= rather than eval
This commit is contained in:
parent
a4f4497207
commit
39b0f5540c
2 changed files with 7 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
|||
2019-04-22 Matthew Martin <phy1729@gmail.com>
|
||||
|
||||
* unposted: Completion/Base/Utility/_pick_variant: Use
|
||||
${(P) ::= rather than eval.
|
||||
|
||||
* 44242: Completion/Unix/Command/_chown,
|
||||
Completion/Unix/Command/_ln, Completion/Unix/Command/_mv,
|
||||
Completion/Unix/Command/_rm, Completion/Unix/Command/_rmdir:
|
||||
|
|
|
@ -17,7 +17,7 @@ done
|
|||
if (( ${#precommands:|builtin_precommands} )); then
|
||||
pre=command
|
||||
elif (( $+opts[-b] && ( $precommands[(I)builtin] || $+builtins[$opts[-c]] ) )); then
|
||||
(( $+opts[-r] )) && eval "${opts[-r]}=$opts[-b]"
|
||||
(( $+opts[-r] )) && : ${(P)opts[-r]::=$opts[-b]}
|
||||
return 0
|
||||
elif (( $precommands[(I)builtin] )); then
|
||||
pre=builtin
|
||||
|
@ -28,7 +28,7 @@ else
|
|||
fi
|
||||
|
||||
if [[ $pre != builtin ]] && (( $+_cmd_variant[$opts[-c]] )); then
|
||||
(( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}"
|
||||
(( $+opts[-r] )) && : ${(P)opts[-r]::=${_cmd_variant[$opts[-c]]}}
|
||||
[[ $_cmd_variant[$opts[-c]] = "$1" ]] && return 1
|
||||
return 0
|
||||
fi
|
||||
|
@ -37,13 +37,13 @@ output="$(_call_program variant $pre $opts[-c] "${@[2,-1]}" </dev/null 2>&1)"
|
|||
|
||||
for cmd pat in "$var[@]"; do
|
||||
if [[ $output = *$~pat* ]]; then
|
||||
(( $+opts[-r] )) && eval "${opts[-r]}=$cmd"
|
||||
(( $+opts[-r] )) && : ${(P)opts[-r]::=$cmd}
|
||||
_cmd_variant[$opts[-c]]="$cmd"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
(( $+opts[-r] )) && eval "${opts[-r]}=$1"
|
||||
(( $+opts[-r] )) && : ${(P)opts[-r]::=$1}
|
||||
[[ $pre != builtin ]] && _cmd_variant[$opts[-c]]="$1"
|
||||
|
||||
return 1
|
||||
|
|
Loading…
Reference in a new issue