From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28635 invoked by alias); 9 Jun 2018 18:22:05 -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: 42971 Received: (qmail 13719 invoked by uid 1010); 9 Jun 2018 18:22:05 -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.765852 secs); 09 Jun 2018 18:22:05 -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-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=VgxvkVdT2g///gfR4zEPEnp2MBYzc 3VyYwc6+2k4xEE=; b=e+qVW6Bbn4YYWxVZ5BQCN35ykWbHbI424Mx+dexgVf7fn nJG0/9qvkTN5MPeoB1bgPS9hCag/0ECQT/MhBhv1NtgV0ZqA1nkJbSTfmZ7eTQtp vvmcfrsQcisra6G+jLvxyNZYucH1fJpI5DJgvfAnM10IjnqvaLTcnHwhkMLaTZF2 KOPquBzFzlNoqb/a9PlHjNP/Yf/CBDbib1gKnjbRgE6DkvWYZ0MXcNGCwIiCt/PO z+nAo6v4RsG8R0mDoRJX2eiu9kCBRs0AXh4HHZcfa9Jec0y95afsm77UxPOzu9wx g2HKdoxzDordm23cc8AbHO6eaKQ76I5A/V0Ab59Mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=VgxvkVdT2g///gfR4zEPEnp2MBYzc 3VyYwc6+2k4xEE=; b=DvsF6V56TLRtlrD4u6UQmXhpP0yCSULHAz4AwN9cqlRRH zwsLTPj8wPQk/QwRIv5HlarES4yxxm3+QBjpqLrEW+V00zGxt5wcCb1K8AW6/tCr mNbXIg2/PPIhiDo41Yr7xug4byfSGLrdlpsf/c4iHBjNJR6MgZ6aJ2j08yDr7quL iZCaTBkD1m7qFTTK2F8TzM4eX4x2G1qWdZ2psb/LSM+aY2xpcotddu3UCqYtYwst TLaw4r5Q63fqy4jht1P+vablDvRiEZG5PHAkpnHXMUnD+zlQjVUMPl/Q7wElAHvP alMPo4N58crMMgNlFUhkHOccvSGZO1D9s702ZTRhQ== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Date: Sat, 9 Jun 2018 18:21:55 +0000 From: Daniel Shahaf To: doron.behar@gmail.com Cc: zsh-workers@zsh.org Subject: Re: [PATCH] _gpg: Use explicit UIDs for state = public keys. Message-ID: <20180609182155.arzktjvvvtnlm57k@tarpaulin.shahaf.local2> References: <20180607144857.8835-1-doron.behar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180607144857.8835-1-doron.behar@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) doron.behar@gmail.com wrote on Thu, Jun 07, 2018 at 17:48:57 +0300: > Use the `--with-colons` option in conjunction with `(f)` and `(@s.:.)` > to parse the output. > Quote the variables used in `_call_program`. > --- > Completion/Unix/Command/_gpg | 71 ++++++++++++++++++++++++++++++++---- > 1 file changed, 64 insertions(+), 7 deletions(-) > > diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg > index 48a36eff2..a09ba3f9e 100644 > --- a/Completion/Unix/Command/_gpg > +++ b/Completion/Unix/Command/_gpg > @@ -206,20 +206,77 @@ 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 > + local public_keys=(${(@s.:.)${(f)"$(_call_program public-keys ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"}}) > + local -a uids_and_emails > + local i > + for i in {1..${#public_keys[@]}}; do > + if [[ ${public_keys[$i]} == "fpr" ]]; then This looks for the string "fpr" in any field, not just in the first column, doesn't it? (Already pointed out earlier) > + i=$((i + 1)) > + local j=$i > + while [[ ${public_keys[$j]} != "fpr" ]] && [ $j -lt ${#public_keys[@]} ]; do > + if [[ ${public_keys[$j]} =~ "@" ]]; then > + local email="${public_keys[$j]}" > + local uid="${public_keys[$i]}" > + uids_and_emails+=("${uid}":"${email}") Here, colons and backslashes in $uid should be escaped for _describe. It may be easier to use the _describe syntax that takes two array names rather than one. > + i=$j > + break > + fi > + j=$((j + 1)) This assignment to $j seems to be a no-op, isn't it? The written value wouldn't be used by anything. >