Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 'sudo chmod' completion of group names



On Tue, 27 Jan 2015 10:06:55 +0000
Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 'sudo chown root:<tab>' completes only unix groups I'm in, rather than all
> groups in the system.  I'd like it to complete all unix groups in the system.
> 
> Would the following make sense? ---
> 
> diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
> index 7a7e591..1faedc3 100644
> --- a/Completion/Unix/Command/_chown
> +++ b/Completion/Unix/Command/_chown
> @@ -32,7 +32,7 @@ _arguments -C -s "$args[@]" '*:files:->files' && ret=0
>  case $state in
>    owner)
>      if [[ $service = chgrp ]] || compset -P '*[:.]'; then
> -      if (( EGID && $+commands[groups] )); then  # except for root
> +      if (( EGID && $+commands[groups] && ! $+funcstack[(r)_sudo] )); then  # except for root
>         _wanted groups expl 'group' compadd $(groups) && return 0
>        fi
>        _groups && ret=0

Yes, that seems a neat solution to the problem, thanks.

pws



Messages sorted by: Reverse Date, Date, Thread, Author