Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _gpg: Use explicit UIDs for state = public keys.
- X-seq: zsh-workers 42942
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _gpg: Use explicit UIDs for state = public keys.
- Date: Thu, 7 Jun 2018 17:48:57 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=pFxxNxGnWtTDjm3b1FBOeile7NxG+VVJW4fDi6Wwwxc=; b=t0rDQB8Dco+5PP6OqtyInZvrM4u6CKEp6TLYi/BuPTm/YTfPaToLm2BiYSA1T6KR8T pJoHKR+ZmmRC29Sh3HIaLcXUJepCV6vbKnH6+ObH+mWRLMzYePatixouu7+PD8C0btol sLTxgsHaOre618sdsNlrQA8cYmQtVGPivVOsda1I/MFE8w+kGbaWnoeTsSldJEBDXExV zZKR+TWAi0JreOrdsfKeKoaOTW9fWQsEYUPwF4S/GriwpbTg0NKZBwEMj4/NysON3c4l pM3n0cjLtbjGvQ/qFEDwV2I9Gxew5EqeMxzt4tD0D6r1FMjADXm26pT2lzkBmvcAz8XV RWKw==
- 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
From: Doron Behar <doron.behar@xxxxxxxxx>
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
+ 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}")
+ i=$j
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t public-keys 'public key' uids_and_emails
;;
secret-keys)
- _wanted secret-keys expl 'secret key' compadd \
- ${${(Mo)$(_call_program secret-keys $words[1] $needed --list-secret-keys --list-options no-show-photos):%<*>}//(<|>)/} && return
+ local secret_keys=(${(@s.:.)${(f)"$(_call_program secret-keys ${(q)words[1]} ${(q)needed} --list-secret-keys --list-options no-show-photos --with-colons)"}})
+ local -a uids_and_emails
+ local i
+ for i in {1..${#secret_keys[@]}}; do
+ if [[ ${secret_keys[$i]} == "fpr" ]]; then
+ i=$((i + 1))
+ local j=$i
+ while [[ ${secret_keys[$j]} != "fpr" ]] && [ $j -lt ${#secret_keys[@]} ]; do
+ if [[ ${secret_keys[$j]} =~ "@" ]]; then
+ local email="${secret_keys[$j]}"
+ local uid="${secret_keys[$i]}"
+ uids_and_emails+=("${uid}":"${email}")
+ i=$j
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t secret-keys 'secret key' uids_and_emails
;;
ciphers)
_wanted ciphers expl cipher compadd \
- ${${(s.,.)${(M)${(f)${"$(_call_program ciphers $words[1] $needed --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return
+ ${${(s.,.)${(M)${(f)${"$(_call_program ciphers ${(q)words[1]} ${(q)needed} --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return
;;
(public-keyids)
- _wanted public-keys expl 'public keyid' \
- compadd ${(M)${${(f)"$(_call_program public-keyids $words[1] $needed --list-public-keys --list-options no-show-photos)"}## #}:#[0-9A-F](#c40)} && 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
+ 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}")
+ i=$j
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t public-keyids 'public keyids' uids_and_emails
;;
(option-list)
_sequence _wanted options expl option \
--
2.17.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author