zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] sudo strace -e <TAB>
Date: Sat, 7 Mar 2015 04:27:33 +0000	[thread overview]
Message-ID: <20150307042733.GF2206@tarsus.local2> (raw)

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


             reply	other threads:[~2015-03-07  4:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-07  4:27 Daniel Shahaf [this message]
2015-03-07  7:42 ` Bart Schaefer
2015-03-09 19:57   ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150307042733.GF2206@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).