mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 22:51:42 +02:00
34693: sudo completion: Don't false positive 'sudo -e' detection
This commit is contained in:
parent
c1eda67909
commit
69ada95acd
2 changed files with 11 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
||||||
2015-03-09 Daniel Shahaf <d.s@daniel.shahaf.name>
|
2015-03-09 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||||
|
|
||||||
|
* 34693: Completion/Unix/Command/_sudo: sudo completion: Don't
|
||||||
|
false positive 'sudo -e' detection
|
||||||
|
|
||||||
* 34693: Completion/Linux/Command/_strace: _strace: Fix variable
|
* 34693: Completion/Linux/Command/_strace: _strace: Fix variable
|
||||||
leakage of $sys_calls
|
leakage of $sys_calls
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#compdef sudo sudoedit
|
#compdef sudo sudoedit
|
||||||
|
|
||||||
|
setopt localoptions extended_glob
|
||||||
|
|
||||||
local environ e
|
local environ e
|
||||||
local -a args
|
local -a args
|
||||||
|
|
||||||
|
@ -29,7 +31,12 @@ args=(
|
||||||
'(-v --validate)'{-v,--validate}"[update user's timestamp without running a command]"
|
'(-v --validate)'{-v,--validate}"[update user's timestamp without running a command]"
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ $service = sudoedit || -n ${words[(r)-e]} ]]; then
|
# Does -e appears before the first word that doesn't begin with a hyphen?
|
||||||
|
# The way (i) works in subscripts, the test will always be true if all the
|
||||||
|
# words begin with a hyphen.
|
||||||
|
#
|
||||||
|
# TODO: use _arguments' $opt_args to detect the cases '-u jrandom -e' and '-Ae'
|
||||||
|
if [[ $service = sudoedit ]] || (( $words[(i)-e] < $words[(i)^(*sudo|-[^-]*)] )) ; then
|
||||||
args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' )
|
args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' )
|
||||||
else
|
else
|
||||||
args+=(
|
args+=(
|
||||||
|
|
Loading…
Reference in a new issue