From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 52d1cb6f for ; Thu, 21 Mar 2019 00:17:31 +0000 (UTC) Received: (qmail 11735 invoked by alias); 21 Mar 2019 00:17:16 -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: List-Unsubscribe: X-Seq: 44151 Received: (qmail 28194 invoked by uid 1010); 21 Mar 2019 00:17:16 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f66.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25393. spamassassin: 3.4.2. Clear:RC:0(209.85.210.66):SA:0(-1.7/5.0):. Processed in 3.282653 secs); 21 Mar 2019 00:17:16 -0000 X-Envelope-From: phy1729@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.66 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ArN0NoOTR0vUlxTHAf+Tb7UQ56s0vCBODHnYGz5Xllo=; b=cSHKMWmkjnjbQqTU8idT2KZC1g2ZnU3tPxIrUIMtvAaSX2OjgxMvGkCWQlv60DpCIR tqv2k7REsad9NtYVUR9bo8cY+2+T6gCxVD7JvRHn0hz6FBKYY0hf4Mq5y1DeC7G0+irb axHQ0+C6ku/UeHTO/hW0YtwgeVOgjeES6aVk4wRyXu4zrPxpKTZgcoS/8WnInzCEOOvt PYl/qVEUwchj8QN/OlvpThoDo9a6DrgOarE0qT8MSL337EPI6wxldI9Dnog+bXbhF3Uw SJG4F8sNbVcfooiKZwsyAiaGsaNYAVIJAWWcW8A9WJctx9WlTQD3w8sdiAsGvw01LY9f 3ySA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=ArN0NoOTR0vUlxTHAf+Tb7UQ56s0vCBODHnYGz5Xllo=; b=b8NOyOItxWmUDWtxH+0CUzInEOqdDLIYzsDtAsBXfaBjz3FFPEr8BxcVf2+3CmJ5Lt 4ziPPkqfGsfx4+AjRARi+0xrKy5ZCRuTkBI9sHJfZ+JbXvc5BB8Kdl6W9Q2cxDUSsHKJ r1Q9ApJN6YDDzG7I/ipeEyR2mrUC5ic0/QmXFvFJdp38hkepZblUOpAOYoX8XKHFnuMf 9Pn0gNUBBc6zGDYneG+X7tnnkMWZh3nJojBt3lRqa10VQlNTat6/iZZ0hVrtWAngBAoC r0i0rssrHapNZt4+5ZdgJ6xuguwNi2KpUZj1Cbx9seLb8rmCFZMrQRQSPGCYOCmP7qCB j9Ww== X-Gm-Message-State: APjAAAWoXL3FLsKpZMpzZ4hm/QVFPTA3cD/zRhIVoTeRr5/8swcZLhuw fqPhw4YARBJdabQS2f4e6TeI4HZM X-Google-Smtp-Source: APXvYqznVn+Fy4XeeGNHI9JPI836men/mZvujjZVXg7yL8oe3r0td2JymmW54iIgEFEPc1oUj6vutA== X-Received: by 2002:a9d:d66:: with SMTP id 93mr620978oti.25.1553127399983; Wed, 20 Mar 2019 17:16:39 -0700 (PDT) Date: Wed, 20 Mar 2019 19:16:37 -0500 From: Matthew Martin To: Daniel Shahaf Cc: zsh-workers@zsh.org Subject: Re: [PATCH] _pick_variant: Update builtin check Message-ID: <20190321001636.GA57147@CptOrmolo.darkstar> Mail-Followup-To: Daniel Shahaf , zsh-workers@zsh.org References: <20190320020511.GA6739@CptOrmolo.darkstar> <20190320033815.GA22718@CptOrmolo.darkstar> <20190320125238.GA48465@CptOrmolo.darkstar> <20190320130523.rwpxbzi4u66i2srz@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190320130523.rwpxbzi4u66i2srz@tarpaulin.shahaf.local2> User-Agent: Mutt/1.11.4 (2019-03-13) On Wed, Mar 20, 2019 at 01:05:23PM +0000, Daniel Shahaf wrote: > Matthew Martin wrote on Wed, Mar 20, 2019 at 07:52:39 -0500: > > There are four booleans in play: > > - If command (or a non-builtin-preserving precommand) is specified > > (${#precommands:|builtin_precommands}) > > - If builtin is specified ($+precommands[(r)builtin]) > > - If -b is passed to _pick_variant ($+opts[-b]) > > - If the command is a builtin ($+builtins[$opts[-c]]) > ⋮ > > +++ b/Completion/Base/Utility/_pick_variant > > @@ -1,9 +1,11 @@ > > #autoload > > > > -local output cmd pat > > -local -a var > > +local output cmd pat pre > > +local -a builtin_precommands var > > local -A opts > > > > +builtin_precommands=(- builtin eval exec nocorrect noglob time) > > May I suggest a comment here documenting the semantics of this variable? > For example, why doesn't it list the 'command' precommand (presumably > becaus that one doesn't preserve builtins, but this info should be in > the comment, not in the list archives)? How's +# Precommands which allow the command to be builtin (unlike command and sudo). +local -ar builtin_precommands=(- builtin eval exec nocorrect noglob time) Which of course raises the point that I need to add precommands+=(sudo) to _sudo (and most users of _normal). > (And since I'm replying already, style nit: the array could be declared > readonly.) Indeed; fixed. > > (( $+_cmd_variant )) || typeset -gA _cmd_variant > > > > zparseopts -D -A opts b: c: r: > > @@ -13,19 +15,27 @@ while [[ $1 = *=* ]]; do > > var+=( "${1%%\=*}" "${1#*=}" ) > > shift > > done > > -if (( $+_cmd_variant[$opts[-c]] )); then > > - (( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}" > > - [[ $_cmd_variant[$opts[-c]] = "$1" ]] && return 1 > > + > > +if (( ${#precommands:|builtin_precommands} )); then > > + pre=command > > +elif (( $+opts[-b] && ( $precommands[(r)builtin] || $+builtins[$opts[-c]] ) )); then > > + (( $+opts[-r] )) && eval "${opts[-r]}=$opts[-b]" > > Should that be «"${opts[-r]}=${(q)opts[-b]}"» with quoting to counter > the eval? (Also with the preëxisting assignments-in-eval in other lines) I was planning on switching them all to ${(P)opts[-r]::=...} next. Thanks for the review!