summaryrefslogtreecommitdiff
path: root/Completion/User/_yp
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_yp')
-rw-r--r--Completion/User/_yp50
1 files changed, 29 insertions, 21 deletions
diff --git a/Completion/User/_yp b/Completion/User/_yp
index 85d783b06..5b0c86143 100644
--- a/Completion/User/_yp
+++ b/Completion/User/_yp
@@ -1,11 +1,11 @@
#compdef ypcat ypmatch yppasswd ypwhich ypset ypserv ypbind yppush yppoll ypxfr domainname
-local line state ret=1
-typeset -A options
+local curcontext="$curcontext" line state ret=1
+typeset -A opt_args
if (( ! $+_yp_cache_maps )); then
- _yp_cache_maps=( "${(@)${(@f)$(ypwhich -m)}%% *}" )
- _yp_cache_nicks=( "${(@)${(@)${(@f)$(ypwhich -x)}#*\"}%%\"*}" )
+ _yp_cache_maps=( "${(@)${(@f)$(_call maps ypwhich -m)}%% *}" )
+ _yp_cache_nicks=( "${(@)${(@)${(@f)$(_call names ypwhich -x)}#*\"}%%\"*}" )
_yp_args=(
'(-x)-d[specify domain]:domain name:' \
'(-x)-k[display keys]' \
@@ -14,19 +14,19 @@ if (( ! $+_yp_cache_maps )); then
)
fi
-case "$words[1]" in
+case "${words[1]:t}" in
ypcat)
- _arguments -s "$_yp_args[@]" ':map name:->map' && ret=0
+ _arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0
;;
ypmatch)
- _arguments -s "$_yp_args[@]" '*::key map:->keymap' && ret=0
+ _arguments -C -s "$_yp_args[@]" '*::key map:->keymap' && ret=0
;;
yppasswd)
_users
return
;;
ypwhich)
- _arguments \
+ _arguments -C \
'(-x)-d[specify domain]:domain name:' \
'(-x -V2 -m -t)-V1[identify version 1 servers]' \
'(-x -V1 -m -t)-V2[identify version 2 servers]' \
@@ -36,7 +36,7 @@ ypwhich)
':host:_hosts' && ret=0
;;
ypset)
- _arguments \
+ _arguments -C \
'(-V2)-V1[bind version 1 servers]' \
'(-V1)-V2[bind version 2 servers]' \
'-d[specify domain]:domain name:' \
@@ -44,30 +44,30 @@ ypset)
':server:_hosts' && ret=0
;;
ypserv)
- _arguments \
+ _arguments -C \
'-a[specify database routines]:database routines:((b\:btree d\:dbm/ndbm h\:hash))' && ret=0
;;
ypbind)
- _arguments \
+ _arguments -C \
'-s[allow secure mode for ypbind]' \
'-S[set domain and servers]:domain:->servers' \
'(-ypsetme)-ypset[accept all ypset requests]' \
'(-ypset)-ypsetme[accept only local ypset requests]' && ret=0
;;
yppush)
- _arguments \
+ _arguments -C \
'-d[specify domain]:domain name:' \
'-v[print messages]' \
':map name:->map' && ret=0
;;
yppoll)
- _arguments \
+ _arguments -C \
'-d[specify domain]:domain name:' \
'-h[specify host]:ask server on host:_hosts' \
':map name:->map' && ret=0
;;
ypxfr)
- _arguments \
+ _arguments -C \
'-a[specify database routines]:database routines:((b\:btree d\:dbm/ndbm h\:hash))' \
'-f[force transfer]' \
'-c[don'"'"'t clear current map]' \
@@ -87,16 +87,24 @@ esac
if [[ "$state" = map* ]]; then
local expl
- _description expl 'map name'
- compadd "$expl[@]" - "$_yp_cache_maps[@]" && ret=0
- if [[ $+options[-t] -eq 0 && "$state" != maponly ]]; then
- _description expl 'nicknames'
- compadd "$expl[@]" - "$_yp_cache_nicks[@]" && ret=0
+ if [[ $+opt_args[-t] -eq 0 && "$state" != maponly ]]; then
+ _tags maps nicknames
+ else
+ _tags maps
fi
+
+ while _tags; do
+ # 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:|=*' - \
+ "$_yp_cache_maps[@]" && ret=0
+ _requested nicknames expl nicknames \
+ compadd - "$_yp_cache_nicks[@]" && ret=0
+ (( ret )) || return 0
+ done
elif [[ "$state" = servers ]]; then
if compset -P '*,'; then
- _description expl 'server'
- _hosts -qS, && ret=0
+ _wanted hosts expl server _hosts -qS, && ret=0
else
_message 'domain name'
fi