diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2001-05-09 15:27:01 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2001-05-09 15:27:01 +0000 |
commit | 7f4eb970858cfd8f2a1e4dd716c403623a23a066 (patch) | |
tree | 0373fca7e37df653b938b6def67d0ca9dec70936 /Completion/Unix/Command | |
parent | e364fb2139df94df3c4aac406e56b133d3e497b1 (diff) | |
download | zsh-7f4eb970858cfd8f2a1e4dd716c403623a23a066.tar.gz zsh-7f4eb970858cfd8f2a1e4dd716c403623a23a066.tar.xz zsh-7f4eb970858cfd8f2a1e4dd716c403623a23a066.zip |
complete only files that can be chowned (14282)
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r-- | Completion/Unix/Command/_chown | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown index 40f38d2f4..83fcb3056 100644 --- a/Completion/Unix/Command/_chown +++ b/Completion/Unix/Command/_chown @@ -1,10 +1,13 @@ #compdef chown chgrp -local suf +local suf usr grp req expl if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then if [[ $service = chgrp ]] || compset -P '*[:.]'; then - _groups + if (( EGID && $+commands[groups] )); then # except for root + _wanted groups expl 'group' compadd $(groups) && return 0 + fi + _groups && return 0 else if [[ $OSTYPE = (solaris*|hpux*) ]]; then suf=':' @@ -12,8 +15,19 @@ if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then suf='.' fi compset -S '.*' && unset suf - _users -S "$suf" -q + _users -S "$suf" -q && return 0 fi else - _files + if [[ $service = chgrp ]]; then + grp=${words[CURRENT-1]} + else + usr=${words[CURRENT-1]%%[.:]*} + usr=${${(M)usr:#[0-9]#}:-${userdirs[$usr]:+.$usr.}} + grp=${${(M)words[CURRENT-1]%%[.:]*}#?} + fi + [[ -n $grp ]] && grp="${${(M)grp:#[0-9]#}:-.$grp.}" + req=( ${usr:+\^u$usr} ${grp:+\^g$grp} ) + (( EUID )) && req=( u$EUID$^req ) + + _files -g "*(${(j:,:)req})" && return 0 fi |