From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5246 invoked by alias); 7 Mar 2015 04:27:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34674 Received: (qmail 8737 invoked from network); 7 Mar 2015 04:27:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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 = X-Sasl-enc: bXEUFMcVv3oemvkQqgLoB4c5K7HUMoWMvZE/RVzYzAt3 1425702455 Date: Sat, 7 Mar 2015 04:27:33 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] sudo strace -e Message-ID: <20150307042733.GF2206@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 ' completes files, while 'strace -e ' 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