Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] sudo strace -e <TAB>
- X-seq: zsh-workers 34674
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] sudo strace -e <TAB>
- Date: Sat, 7 Mar 2015 04:27:33 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=x-sasl-enc:date:from:to:subject:message-id :mime-version:content-type; s=mesmtp; bh=kEaP5IOdlXZ0W1eqXX+QUp+ REQ8=; b=pvjzN9WL7eSGFq+gyRMrhzewopIAweez5x7bjiQUd8zy7gB28AsWNRk 4ebTG90I0TMCb/BeJUH9WIrpoT45VQdTNDG2y27cWKEuiydRgWvgC8PtVX+/g4Nm iLxsQRfAM7UUxtB14rdgQeIlTaTa4b+zS4ezAEtm4CxQFVobtOt4=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:date:from:to:subject :message-id:mime-version:content-type; s=smtpout; bh=kEaP5IOdlXZ 0W1eqXX+QUp+REQ8=; b=hlXhNX4eZANzxHd8j3grh28b8TCmKniFTxqLw/DNxSY qsr5RwzhMA+VLZy2MR1QvTcd1kgdwNPgzAN+956oSEJaZXqM9bstmEOr1htRWRiZ 5zD1cpnNdDaZff53MT8KU/s9YEZl9iaxnbhJrLD2cdeugF76H+Uh4jYVylTQq0M4 =
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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