26763: fix problem on failed cd -s to relative path
[zsh.git] / Completion / Unix / Type / _groups
bloba5624269e9cf12039860e6406195b778909d67c8
1 #compdef newgrp groupdel
3 local expl groups tmp
5 _tags groups || return 1
7 if ! zstyle -a ":completion:${curcontext}:" groups groups; then
8   (( $+_cache_groups )) ||
9       if [[ $OSTYPE = darwin* ]]; then
10         if (( ${+commands[lookupd]} )); then 
11           : ${(A)_cache_groups:=${${(M)${(f)"$(_call_program groups lookupd -q group)"}:#name*}##*: }}
12         elif (( ${+commands[dscacheutil]} )); then
13           : ${(A)_cache_groups:=${${(M)${(f)"$(_call_program groups dscacheutil -q group)"}:#name*}##*: }}
14         fi
15       elif (( ${+commands[getent]} )); then
16         : ${(A)_cache_groups:=${${(s: :)$(_call_program groups getent group 2>/dev/null)}%%:*}}
17       else
18         : ${(A)_cache_groups:=${${${(s: :)$(</etc/group)}%%:*}:#+}}
19         if (( ${+commands[ypcat]} )) &&
20             tmp=$(_call_program groups ypcat group.byname 2>/dev/null); then
21           _cache_groups+=( ${${(f)tmp}%%:*} ) # If you use YP
22         fi
23       fi
25   groups=( "$_cache_groups[@]" )
28 _wanted groups expl group compadd -a "$@" - groups