From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24600 invoked by alias); 26 May 2018 16:36:14 -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: 42859 Received: (qmail 912 invoked by uid 1010); 26 May 2018 16:36:14 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.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(66.111.4.25):SA:0(-2.6/5.0):. Processed in 2.226915 secs); 26 May 2018 16:36:14 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=HcmPRS GBBTYOrfpSOn1MoEonlpwn680iNu4V4EkwZdU=; b=R3iN7IIfJuSSC3FPJoYfB5 Rebx/E3yj0UzjOgdOfo8nd+2YApY2GGVAm6m1ZPf7kQSri73vj4e3DUx/XjaZ4Ss 4eosfLq6ZO6sx1laF729TSsQIFyS5lnpV0kdN29CHdo5nXNOnJkmYyFQG6vVJIaR A1XXplWGT1kRU2kPA5E9S22WYO55Cm3tnlCIdG73w6pimOBNltwjLX66/GTKS3l0 zrvSBdvhn6sLiatYRCvP/sVkr/BSmLE71//wboGDpEuiCKPhFmOSYqclYY12UJBq judXc8mZL0bm2GwubzfFqUkL/dCetc90ST4QQxL4IMYbW1iLe80qty4H9834o4SA == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=HcmPRS GBBTYOrfpSOn1MoEonlpwn680iNu4V4EkwZdU=; b=Sz7OLWoBr1Uuz+bKxgxK3z hIJAmV7eXga3axk+eph4HpZbFl2O9t6gnAzeSDxzc78pHe/rUycverTM8kIfTplM qrNopIGc+jkYiD/UWLSI00NhX5H8JsDAgrzx93u115S7HJGSa+1iJjNiR2nDT7La 8KmJAcJ0zZAhU5toIniDz2OPg5lT7oiltaRzOgjXNxRKKreZ497ywsnusoufjWN0 0d1tzAoe9sxOVVchW7kJ3EVy2WwEC771IMGyJsuSTkJ2KxRP+8ptDQqZ7m0AvRNb /rzVKFeVa4Pe4sFa2X8DKt9I7clgfzZb4mTJTc9tEPhE6fQc5VuGtybfA6qEFNjQ == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Date: Sat, 26 May 2018 16:25:41 +0000 From: Daniel Shahaf To: doron.behar@gmail.com Cc: zsh-workers@zsh.org Subject: Re: [PATCH 1/1] _gpg: Use explicit UIDs for state = public keys. Message-ID: <20180526162541.ejfzrpqwl5lwjkzb@tarpaulin.shahaf.local2> References: <20180526151628.17983-1-doron.behar@gmail.com> <20180526151628.17983-2-doron.behar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180526151628.17983-2-doron.behar@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) 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