Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] _gpg: Use explicit UIDs for state = public keys.
- X-seq: zsh-workers 42971
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: doron.behar@xxxxxxxxx
- Subject: Re: [PATCH] _gpg: Use explicit UIDs for state = public keys.
- Date: Sat, 9 Jun 2018 18:21:55 +0000
- Cc: zsh-workers@xxxxxxx
- 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==
- In-reply-to: <20180607144857.8835-1-doron.behar@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180607144857.8835-1-doron.behar@gmail.com>
doron.behar@xxxxxxxxx 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.
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author