mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-11-19 21:44:11 +01:00
complete only files that can be chowned (14282)
This commit is contained in:
parent
e364fb2139
commit
7f4eb97085
@ -1,5 +1,8 @@
|
|||||||
2001-05-09 Oliver Kiddle <opk@zsh.org>
|
2001-05-09 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 14282: Completion/Unix/Command/_chown: complete only files
|
||||||
|
that can be chowned.
|
||||||
|
|
||||||
* 14281: Completion/Base/Completer/_expand: insert redirection
|
* 14281: Completion/Base/Completer/_expand: insert redirection
|
||||||
operators when expanding after a redirection operator.
|
operators when expanding after a redirection operator.
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#compdef chown chgrp
|
#compdef chown chgrp
|
||||||
|
|
||||||
local suf
|
local suf usr grp req expl
|
||||||
|
|
||||||
if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
|
if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
|
||||||
if [[ $service = chgrp ]] || compset -P '*[:.]'; 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
|
else
|
||||||
if [[ $OSTYPE = (solaris*|hpux*) ]]; then
|
if [[ $OSTYPE = (solaris*|hpux*) ]]; then
|
||||||
suf=':'
|
suf=':'
|
||||||
@ -12,8 +15,19 @@ if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
|
|||||||
suf='.'
|
suf='.'
|
||||||
fi
|
fi
|
||||||
compset -S '.*' && unset suf
|
compset -S '.*' && unset suf
|
||||||
_users -S "$suf" -q
|
_users -S "$suf" -q && return 0
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user