1#compdef ypcat ypmatch yppasswd ypwhich ypset ypserv ypbind yppush yppoll ypxfr domainname 2 3local curcontext="$curcontext" line state expl args ret=1 4typeset -A opt_args 5 6if (( ! $+_cache_yp_maps )); then 7 typeset -ga _cache_yp_maps _cache_yp_nicks 8 _cache_yp_maps=( "${(@)${(@f)$(_call_program maps ypwhich -m)}%% *}" ) 9 _cache_yp_nicks=( "${(@)${(@)${(@f)$(_call_program names ypwhich -x)}#*\"}%%\"*}" ) 10fi 11 12args=( 13 '(-x)-d[specify domain]:domain name' \ 14 '(-x)-k[display keys]' \ 15 '(-x)-t[inhibit nicknames]' \ 16 '(: -d -k -t)-x[display nicknames]' \ 17) 18 19case "$service" in 20ypcat) 21 _arguments -C -s $args ':map name:->map' && ret=0 22 ;; 23ypmatch) 24 _arguments -C -s $args '::key map:->keymap' ':map name:->map' && 25 ret=0 26 ;; 27yppasswd) 28 _users 29 return 30 ;; 31ypwhich) 32 _arguments -C \ 33 '(-x)-d[specify domain]:domain name' \ 34 '(-x -V2 -m -t)-V1[identify version 1 servers]' \ 35 '(-x -V1 -m -t)-V2[identify version 2 servers]' \ 36 '(: -x -V1 -V2 -m)-t[specify map name]:map name:->maponly' \ 37 '(: -x -V1 -V2 -t)-m[specify map or nick name]:map or nick name:->map' \ 38 '(: -d -m -t -V1 -V2)-x[display nicknames]' \ 39 ':host:_hosts' && ret=0 40 ;; 41ypset) 42 _arguments -C \ 43 '(-V2)-V1[bind version 1 servers]' \ 44 '(-V1)-V2[bind version 2 servers]' \ 45 '-d[specify domain]:domain name' \ 46 '-h[set NIS binding on specified host]:host:_hosts' \ 47 ':server:_hosts' && ret=0 48 ;; 49ypserv) 50 _arguments -C \ 51 '-a[specify database routines]:database routines:((b\:btree d\:dbm/ndbm h\:hash))' && ret=0 52 ;; 53ypbind) 54 _arguments -C \ 55 '-s[allow secure mode for ypbind]' \ 56 '-S[set domain and servers]:domain:->servers' \ 57 '(-ypsetme)-ypset[accept all ypset requests]' \ 58 '(-ypset)-ypsetme[accept only local ypset requests]' && ret=0 59 ;; 60yppush) 61 _arguments -C \ 62 '-d[specify domain]:domain name' \ 63 '-v[print messages]' \ 64 ':map name:->map' && ret=0 65 ;; 66yppoll) 67 _arguments -C \ 68 '-d[specify domain]:domain name' \ 69 '-h[ask specified yp server]:host:_hosts' \ 70 ':map name:->map' && ret=0 71 ;; 72ypxfr) 73 _arguments -C \ 74 '-a[specify database routines]:database routines:((b\:btree d\:dbm/ndbm h\:hash))' \ 75 '-f[force transfer]' \ 76 "-c[don't clear current map]" \ 77 '-d[specify domain]:domain name' \ 78 '-h[get map from specified host instead of master]:host:_hosts' \ 79 '-C[call back]:transaction ID: :program number: :IP address: :port number' \ 80 ':map name:->map' && ret=0 81 ;; 82domainname) 83 _message -e new-domains 'new domain name' 84 return 1 85 ;; 86esac 87 88[[ "$state" = keymap ]] && _message -e keys 'key' 89 90if [[ "$state" = map* ]]; then 91 if [[ $+opt_args[-t] -eq 0 && "$state" != maponly ]]; then 92 _tags maps nicknames 93 else 94 _tags maps 95 fi 96 97 while _tags; do 98 # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'. 99 _requested maps expl 'map name' \ 100 compadd -M 'l:.|by=by l:.|=by r:|.=* r:|=*' -a \ 101 _cache_yp_maps && ret=0 102 _requested nicknames expl nicknames \ 103 compadd -a _cache_yp_nicks && ret=0 104 (( ret )) || return 0 105 done 106elif [[ "$state" = servers ]]; then 107 if compset -P '*,'; then 108 _wanted hosts expl server _hosts -qS, && ret=0 109 else 110 _message -e domains 'domain name' 111 fi 112fi 113 114return ret 115