From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7341 invoked by alias); 29 May 2018 14:11:29 -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: 42877 Received: (qmail 14186 invoked by uid 1010); 29 May 2018 14:11:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f65.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.65):SA:0(-1.9/5.0):. Processed in 1.322495 secs); 29 May 2018 14:11:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: doron.behar@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=e0vjnnKIDfkFCOBaqNVygnH78zqv5k0WBrF/gFLI350=; b=qx/YT+iRR6qplKPttrKTBf+ehSQExbX78Qc3j6f6eRaCQuhtITwdObBna6pVDY4wN+ IteWBGMX4gv7/A5gnISqQWe3XY8j/SEk3WISXtPcFAnqchm4yLfmwucx5DHWQPcQz9IZ DsE7Yix/Mh99WyxdYrEpWACuo4c7RWtbYLbv74e8wjq3fwkhyZd79zclPJHsFt9tQb8D T9781lk4uQahooT7ir+xzOfppOYbEOra+3B4YG0niAFM53ayrOn2GGlOSh9B9hWcolYq VszYCFrT3WsdNSb0++0uPQeqMlND3XK/BI4jCRhkKSiBLJ2/VAaG4y3DeFUe+0n+dTAq hdOw== 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:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=e0vjnnKIDfkFCOBaqNVygnH78zqv5k0WBrF/gFLI350=; b=OB9va3UWTvbAZiS21c4uEfvk6yQrkMArpaajgv2Qiql2qw2bJVaHx0kTB8M78OFBF5 uO//K2SuEMP+7CuR6G7kk7b/oMyCG3VhMdNmvR8dpBaJL3udzMcHIahvcDi5IwF4vRdv Gw977rWfbH0g77Y3BJaK7qpD/1z28fB5dy+BfdE5FpTimJWBbo8ISB+QVvniRL2tz/03 eysPykUgjgfndhb2oXls+rVbcmSFnQK9uCIhXbfVcesZJo2i4Y5Qfjv/csSUjqk+3OF3 4gdqLrT/LsUSCP6sNnUr3iQaAmtQb0bqYNWezK5TioH3XxEBXmkaKnKqR3qce2R8U1fu uLhA== X-Gm-Message-State: ALKqPwcoJfH25QIViljyUV1XrX2PeouYHjntoJKcsuFf3yfyPeYYIH+m +7fGqTc92roO1X6YTrjjbZEkfQtC X-Google-Smtp-Source: ADUXVKJ6XHj4OOrTYEU3/33TL8sBAUllx5moQwM5bcmQB6RgC7axYiR+4HEEXu33mxI5qRUwrg5Fug== X-Received: by 2002:a1c:1082:: with SMTP id 124-v6mr10455123wmq.46.1527603084019; Tue, 29 May 2018 07:11:24 -0700 (PDT) Date: Tue, 29 May 2018 17:11:23 +0300 From: Doron Behar To: zsh-workers@zsh.org Subject: Re: [PATCH 1/1] _gpg: Use explicit UIDs for state = public keys. Message-ID: <20180529141034.m45lzzjpjrmo4wjg@NUC.doronbehar.com> Mail-Followup-To: zsh-workers@zsh.org References: <20180526151628.17983-1-doron.behar@gmail.com> <20180526151628.17983-2-doron.behar@gmail.com> <20180526162541.ejfzrpqwl5lwjkzb@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180526162541.ejfzrpqwl5lwjkzb@tarpaulin.shahaf.local2> User-Agent: NeoMutt/20180512 I've successfully managed to solve address all the comments you've had for my patch. Yet, I'm having trouble with `_call_program`. The line I'm trying to put is this: local public_keys=(${(@s.:.)$(_call_program public-keys $words[1] $needed --list-public-keys --list-options no-show-photos --with-colons)}) I debugged this a little bit and the variable `$public_keys` is empty but if I remove the words: `_call_program public-keys` it works good. I've had a glimpse at `htop` when this function was called when I tested the completion function and I saw these commands running there: pkgfile -b -v -- --list-public-keys pkgfile -b -v -- --list-options pkgfile -b -v -- no-show-photos pkgfile -b -v -- --with-colons What is _call_program supposed to be doing? Besides that, the revised patch is ready. I've also included similar improvements for the other states - `secret-keys` and `public-keyids`. On Sat, May 26, 2018 at 04:25:41PM +0000, Daniel Shahaf wrote: > On Sat, May 26, 2018 at 06:16:28PM +0300, doron.behar@gmail.com wrote: > > From: Doron Behar > > > > Use the `--with-colons` option and parse the output while IFS=":" > > according to the output format. > > --- > > Completion/Unix/Command/_gpg | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg > > index 48a36eff2..71fa7667d 100644 > > --- a/Completion/Unix/Command/_gpg > > +++ b/Completion/Unix/Command/_gpg > > @@ -206,8 +206,19 @@ fi > > > > case "$state" in > > public-keys) > > - _wanted public-keys expl 'public key' \ > > - compadd ${${(Mo)$(_call_program public-keys $words[1] $needed --list-public-keys --list-options no-show-photos):%<*>}//(<|>)/} && return > > + OLDIFS="${IFS}" > > OLDIFS isn't made local so it leaks. > > You could alternatively have set IFS in a precommand assignment (e.g., «IFS=: > /bin/echo foo:bar»), or made it local to a function. Another approach is use > parameter expansion flags such as «${(s.:.)foo}». > > > + IFS=":" > > + public_keys=($($words[1] $needed --list-public-keys --list-options no-show-photos --with-colons)) > > Another parameter leak. (See WARN_CREATE_GLOBAL.) > > Why did you remove the use of _call_program? > > > + for i in {1..${#public_keys[@]}}; do > > + if [[ ${public_keys[$i]} =~ "fpr" ]] && [[ ${public_keys[$((i + 19))]} =~ "@" ]] ; then > > The parameter 'i' leaks. > > "fpr" should be looked for as a complete string, not as a substring. Also, it > should be looked for only in the first column, not in every single output > field. > > A subscript is always parsed as a math context so you can just do «$foo[i+9]» > without an additional $((…)) inside. > > > + # +9 is the uid > > + # +19 is the description > > + uids_and_emails+=(${public_keys[$((i + 9))]}":"${public_keys[$((i + 19))]}) > > I'm sorry, but that's not forward compatible. The output format spec > (doc/DETAILS, which is referred to from the manpage) states that fields may be > added in the future, so that "19" may not be hardcoded here. > > > + i=$((i+20)) > > This line doesn't have any effect, does it? This isn't an arithmetic for, it's > a list-of-words for, and the next word is equal to $(( pre_assignment_value_of_i + 1 )). > > > + fi > > + done > > + _describe uids uids_and_emails > > The use of describe doesn't set the 'public-keys' tag that _wanted set. (You > need to pass -t.) > > > + IFS="${OLDIFS}" > > Thanks for the patch. I agree that it would be better to use --with-colons. > We look forward to a revised patch. :-) > > Cheers, > > Daniel