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

[PATCH] sudo strace -e <TAB>



The _sudo completion enters sudoedit mode even if -e is passed to the
command-under-sudo, rather than to sudo itself.  Example: 'sudo strace
-e <TAB>' completes files, while 'strace -e <TAB>' completes syscalls,
as expected.

The following fixes this.  While it causes 'sudo -A -e' to complete
commands rather than files, the alternative syntaxes 'sudoedit -A' and
'sudo -e -A' complete correctly.  Also, the syntax 'sudo -Ae' doesn't
complete either with or without the patch.

I'm inclined to commit this since it there is no workaround for the
'sudo strace -e' breakage, but there is a workaround for the 'sudo -A
-e' breakage.  (Also, I have used the former and never used the latter.)

Is there a smarter way to detect whether -e was passed to sudo?
I couldn't see how to get _arguments to tell me that bit.

diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo
index ee238b4..90b34b3 100644
--- a/Completion/Unix/Command/_sudo
+++ b/Completion/Unix/Command/_sudo
@@ -29,7 +29,7 @@ args=(
   '(-v --validate)'{-v,--validate}"[update user's timestamp without running a command]"
 )
 
-if [[ $service = sudoedit || -n ${words[(r)-e]} ]]; then
+if [[ $service = sudoedit || $words[2] == '-e' ]]; then
   args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' )
 else
   args+=(

Thanks,

Daniel



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