diff options
author | Oliver Kiddle <opk@zsh.org> | 2018-01-03 18:39:55 +0100 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2018-01-03 18:39:55 +0100 |
commit | f7a5211f382077239fdaf1dcc1e58c6649a20df9 (patch) | |
tree | b55a8f41573f2ba5580c3a03851f2c5b88f8025d | |
parent | d81bfa014157315423755b0cdeba15e2d42383fc (diff) | |
download | zsh-f7a5211f382077239fdaf1dcc1e58c6649a20df9.tar.gz zsh-f7a5211f382077239fdaf1dcc1e58c6649a20df9.tar.xz zsh-f7a5211f382077239fdaf1dcc1e58c6649a20df9.zip |
42208: fix use of cache variables in yp completion
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | Completion/Unix/Command/_yp | 30 |
2 files changed, 18 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog index 4f1cfa3c2..c72dcc395 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2018-01-03 Oliver Kiddle <okiddle@yahoo.co.uk> + * 42208: Completion/Unix/Command/_yp: fix use of cache variables + * dana: 42207: Completion/Unix/Command/_chown, Completion/Unix/Command/_cat, Completion/Unix/Command/_cut, Completion/Unix/Command/_dd, Completion/Unix/Command/_df, diff --git a/Completion/Unix/Command/_yp b/Completion/Unix/Command/_yp index b7619a02e..ed3761436 100644 --- a/Completion/Unix/Command/_yp +++ b/Completion/Unix/Command/_yp @@ -1,25 +1,27 @@ #compdef ypcat ypmatch yppasswd ypwhich ypset ypserv ypbind yppush yppoll ypxfr domainname -local curcontext="$curcontext" line state expl ret=1 _yp_cache_nicks _yp_args +local curcontext="$curcontext" line state expl args ret=1 typeset -A opt_args -if (( ! $+_yp_cache_maps )); then - _yp_cache_maps=( "${(@)${(@f)$(_call_program maps ypwhich -m)}%% *}" ) - _yp_cache_nicks=( "${(@)${(@)${(@f)$(_call_program names ypwhich -x)}#*\"}%%\"*}" ) - _yp_args=( - '(-x)-d[specify domain]:domain name' \ - '(-x)-k[display keys]' \ - '(-x)-t[inhibit nicknames]' \ - '(: -d -k -t)-x[display nicknames]' \ - ) +if (( ! $+_cache_yp_maps )); then + typeset -ga _cache_yp_maps _cache_yp_nicks + _cache_yp_maps=( "${(@)${(@f)$(_call_program maps ypwhich -m)}%% *}" ) + _cache_yp_nicks=( "${(@)${(@)${(@f)$(_call_program names ypwhich -x)}#*\"}%%\"*}" ) fi +args=( + '(-x)-d[specify domain]:domain name' \ + '(-x)-k[display keys]' \ + '(-x)-t[inhibit nicknames]' \ + '(: -d -k -t)-x[display nicknames]' \ +) + case "$service" in ypcat) - _arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0 + _arguments -C -s $args ':map name:->map' && ret=0 ;; ypmatch) - _arguments -C -s "$_yp_args[@]" '::key map:->keymap' ':map name:->map' && + _arguments -C -s $args '::key map:->keymap' ':map name:->map' && ret=0 ;; yppasswd) @@ -96,9 +98,9 @@ if [[ "$state" = map* ]]; then # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'. _requested maps expl 'map name' \ compadd -M 'l:.|by=by l:.|=by r:|.=* r:|=*' -a \ - _yp_cache_maps && ret=0 + _cache_yp_maps && ret=0 _requested nicknames expl nicknames \ - compadd -a _yp_cache_nicks && ret=0 + compadd -a _cache_yp_nicks && ret=0 (( ret )) || return 0 done elif [[ "$state" = servers ]]; then |