zsh-workers
 help / color / mirror / code / Atom feed
* 'sudo chmod' completion of group names
@ 2015-01-27 10:06 Daniel Shahaf
  2015-01-27 11:04 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Shahaf @ 2015-01-27 10:06 UTC (permalink / raw)
  To: zsh-workers

'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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: 'sudo chmod' completion of group names
  2015-01-27 10:06 'sudo chmod' completion of group names Daniel Shahaf
@ 2015-01-27 11:04 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2015-01-27 11:04 UTC (permalink / raw)
  To: zsh-workers

On Tue, 27 Jan 2015 10:06:55 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-27 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 10:06 'sudo chmod' completion of group names Daniel Shahaf
2015-01-27 11:04 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).