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

[PATCH] Make $_comp_priv_prefix only declared when required, and use that to have chgrp offer all groups under doas, ssh, etc as well.



---
 Completion/Base/Core/_main_complete | 3 ++-
 Completion/Solaris/Command/_pfexec  | 1 +
 Completion/Solaris/Command/_zlogin  | 3 +--
 Completion/Unix/Command/_chown      | 4 ++--
 Completion/Unix/Command/_doas       | 1 +
 Completion/Unix/Command/_sudo       | 1 +
 6 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index c292ce7..018f2a3 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -38,7 +38,9 @@ local func funcs ret=1 tmp _compskip format nm call match min max i num\
       _saved_colors="$ZLS_COLORS" \
       _saved_colors_set=${+ZLS_COLORS} \
       _ambiguous_color=''
-local -a _comp_priv_prefix
+# Hide any '_comp_priv_prefix' variable that happens to be defined in the calling scope.
+local _comp_priv_prefix
+unset _comp_priv_prefix
 
 # _precommand sets this to indicate we are following a precommand modifier
 local -a precommands
diff --git a/Completion/Solaris/Command/_pfexec b/Completion/Solaris/Command/_pfexec
index 2afaf31..2519c3c 100644
--- a/Completion/Solaris/Command/_pfexec
+++ b/Completion/Solaris/Command/_pfexec
@@ -22,6 +22,7 @@ _privset() {
 }
 
 _pfexec() {
+	local -a _comp_priv_prefix
  	_arguments \
 		'-P[privileges to acquire]:privspec:_privset' \
  		'(-):command name: _command_names -e' \
diff --git a/Completion/Solaris/Command/_zlogin b/Completion/Solaris/Command/_zlogin
index 065f55b..74cbafe 100644
--- a/Completion/Solaris/Command/_zlogin
+++ b/Completion/Solaris/Command/_zlogin
@@ -1,9 +1,8 @@
 #compdef zlogin
 # Synced with the Nevada build 162 man page
 
-local -a _comp_priv_prefix
-
 _zlogin() {
+        local -a _comp_priv_prefix
 	_arguments -s \
 		'-E[Disable escape character]' \
 		'-e[Specify escape character]:character:' \
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index 641b5a7..5750c65 100644
--- a/Completion/Unix/Command/_chown
+++ b/Completion/Unix/Command/_chown
@@ -45,8 +45,8 @@ _arguments -C -s "$args[@]" '*:files:->files' && ret=0
 case $state in
   owner)
     if [[ $service = chgrp ]] || compset -P '*[:.]'; then
-      if (( EGID && $+commands[groups] && ! $+funcstack[(r)_sudo] )); then  # except for root
-       _wanted groups expl 'group' compadd $(groups) && return 0
+      if (( EGID && $+commands[groups] && ! $+_comp_priv_prefix )); then  # except for sudo
+       _wanted groups expl 'group' compadd -- $(groups) && return 0
       fi
       _groups && ret=0
     else
diff --git a/Completion/Unix/Command/_doas b/Completion/Unix/Command/_doas
index b36388e..9439555 100644
--- a/Completion/Unix/Command/_doas
+++ b/Completion/Unix/Command/_doas
@@ -1,6 +1,7 @@
 #compdef doas
 
 local environ e cmd
+local -a _comp_priv_prefix
 
 zstyle -a ":completion:${curcontext}:" environ environ
 
diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo
index 0a212b7..aa7a1a4 100644
--- a/Completion/Unix/Command/_sudo
+++ b/Completion/Unix/Command/_sudo
@@ -4,6 +4,7 @@ setopt localoptions extended_glob
 
 local environ e cmd
 local -a args
+local -a _comp_priv_prefix
 
 zstyle -a ":completion:${curcontext}:" environ environ
 



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