From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: doron.behar@gmail.com
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] _gpg: Use explicit UIDs for state = public keys.
Date: Sat, 9 Jun 2018 18:21:55 +0000 [thread overview]
Message-ID: <20180609182155.arzktjvvvtnlm57k@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20180607144857.8835-1-doron.behar@gmail.com>
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.
>
next prev parent reply other threads:[~2018-06-09 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 14:48 doron.behar
2018-06-09 18:21 ` Daniel Shahaf [this message]
2018-06-09 18:59 ` Doron Behar
2018-06-09 19:23 ` Daniel Shahaf
2018-06-09 19:41 ` Doron Behar
2018-06-18 19:47 doron.behar
2018-06-23 17:26 ` Doron Behar
2018-06-28 13:43 ` Doron Behar
2018-07-01 16:44 ` Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180609182155.arzktjvvvtnlm57k@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=doron.behar@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).