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.
- X-seq: zsh-workers 40011
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Make $_comp_priv_prefix only declared when required, and use that to have chgrp offer all groups under doas, ssh, etc as well.
- Date: Thu, 24 Nov 2016 07:02:11 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=PMp jryp1qiuEPKDg0LJZBlpSp0Q=; b=s5xoah8c9ubTa+fANBG6VoBZx2Jcx9CVGn2 HvvQpl6gWkZID8mhm+VtlpaIlEAqSqgo6NWSgYUoRKQdJNS5RjduZXT/70qkJbFK /0LmpBGZxd/KCN5kTpQSGorQ4lnlsXbPM3dHI/XnolS0QgOsGRq3LF5RedV932en 6UAZEPG8=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=PM pjryp1qiuEPKDg0LJZBlpSp0Q=; b=ViviFTLx9G9LDsBm5sSxT3sbtpT2feXqFi mhoLRwHmNOhNn87bR55KL5YrR4nPHNpwOY3zsjsY+BNEHjv/aw1Ytu35Pa23Vdso inxbAr26dhjp44ZKMLKAorthZl6vSCf4+GW15WCrPDa6nHoPU87OsbuN+Y9oVgCH vKatGYyBs=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
---
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