zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] sudo strace -e <TAB>
@ 2015-03-07  4:27 Daniel Shahaf
  2015-03-07  7:42 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2015-03-07  4:27 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-09 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-07  4:27 [PATCH] sudo strace -e <TAB> Daniel Shahaf
2015-03-07  7:42 ` Bart Schaefer
2015-03-09 19:57   ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).