diff options
author | Oliver Kiddle <opk@zsh.org> | 2016-09-16 00:05:10 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2016-09-16 00:05:10 +0200 |
commit | b870ff85a0bcda9d38a734aa86bb6aee3d76983e (patch) | |
tree | 0c0dfd095a058bc8814dc4ed31dfcabd90bc18a5 /Completion | |
parent | fbafc5b509e311efee064bbd12396a2e207f3393 (diff) | |
download | zsh-b870ff85a0bcda9d38a734aa86bb6aee3d76983e.tar.gz zsh-b870ff85a0bcda9d38a734aa86bb6aee3d76983e.tar.xz zsh-b870ff85a0bcda9d38a734aa86bb6aee3d76983e.zip |
39333: include name of command used to gain priviliges in context for command and gain-priviliges styles
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Base/Utility/_call_program | 9 | ||||
-rw-r--r-- | Completion/Solaris/Command/_pfexec | 2 | ||||
-rw-r--r-- | Completion/Unix/Command/_sudo | 5 |
3 files changed, 10 insertions, 6 deletions
diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program index 95c761e65..9a44f2d8e 100644 --- a/Completion/Base/Utility/_call_program +++ b/Completion/Base/Utility/_call_program @@ -1,12 +1,15 @@ #autoload +X -local tmp err_fd=-1 +local curcontext="${curcontext}" tmp err_fd=-1 local -a prefix if [[ "$1" = -p ]]; then shift - zstyle -t ":completion:${curcontext}:${1}" gain-privileges && - prefix=( $_comp_priv_prefix ) + if (( $#_comp_priv_prefix )); then + curcontext="${curcontext%:*}/${${(@M)_comp_priv_prefix:#^*[^\\]=*}[1]}:" + zstyle -t ":completion:${curcontext}:${1}" gain-privileges && + prefix=( $_comp_priv_prefix ) + fi fi if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]] diff --git a/Completion/Solaris/Command/_pfexec b/Completion/Solaris/Command/_pfexec index 3f1f3e733..2afaf317b 100644 --- a/Completion/Solaris/Command/_pfexec +++ b/Completion/Solaris/Command/_pfexec @@ -25,7 +25,7 @@ _pfexec() { _arguments \ '-P[privileges to acquire]:privspec:_privset' \ '(-):command name: _command_names -e' \ - '*::arguments:{ _comp_priv_prefix=( $words[1] ${(kv)opt_args[-P]} ) ; _normal }' + '*::arguments:{ _comp_priv_prefix=( pfexec ${(kv)opt_args[-P]} ) ; _normal }' } _pfexec "$@" diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo index 21b1ef4c6..0a212b723 100644 --- a/Completion/Unix/Command/_sudo +++ b/Completion/Unix/Command/_sudo @@ -2,7 +2,7 @@ setopt localoptions extended_glob -local environ e +local environ e cmd local -a args zstyle -a ":completion:${curcontext}:" environ environ @@ -39,6 +39,7 @@ args=( if [[ $service = sudoedit ]] || (( $words[(i)-e] < $words[(i)^(*sudo|-[^-]*)] )) ; then args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' ) else + cmd="$words[1]" args+=( '(-e --edit 1 *)'{-e,--edit}'[edit files instead of running a command]' \ '(-s --shell)'{-s,--shell}'[run shell as the target user; a command may also be specified]' \ @@ -48,7 +49,7 @@ else '(-H --set-home -i --login -s --shell -e --edit)'{-H,--set-home}"[set HOME variable to target user's home dir]" \ '(-P --preserve-groups -i -login -s --shell -e --edit)'{-P,--preserve-groups}"[preserve group vector instead of setting to target's]" \ '(-)1:command: _command_names -e' - '*::arguments:{ _comp_priv_prefix=( $words[1] -n ${(kv)opt_args[(I)(-[ugHEP]|--(user|group|set-home|preserve-env|preserve-groups))]} ) ; _normal }' + '*::arguments:{ _comp_priv_prefix=( $cmd -n ${(kv)opt_args[(I)(-[ugHEP]|--(user|group|set-home|preserve-env|preserve-groups))]} ) ; _normal }' ) fi |