Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _gpg: Use explicit UIDs for public / secret keys.
- X-seq: zsh-workers 42975
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _gpg: Use explicit UIDs for public / secret keys.
- Date: Sat, 9 Jun 2018 23:09:40 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=bb3Nv2l3ZvmYQe1/vQxfZIrw4GeQTjs9+d2gEB9AT0I=; b=hPi/Nz9ucJZ1mqqpDgaHvshfmDLwz4xK+IlT4pCHxN+S2L4bxYjTkzGa3SQLD8mIf2 bDqxabc9z8zmEUse2SbGtOCo7QUth65d41z8Kj6/NAewFO0Z706WJK0GdUTm4gnho6H/ ku3h/6JdzwxfI8WPpGX482WaUrpbVHSjGOsZlWXNCfwxzF8f5X6Mw1ZEDc49e2v98/i4 BryNL9MDxadT202H0NJQ/qnTHQ52/NWQxHa38ac5KqtoNw4pBovqAecs+Wm7bLd5stZK F45RBxinCE+RiUXilWbaj3wInpP9SC/F3zVRSJWcz3jMg+2dGyR/rVjqtZJr1XgSYytL 0mbA==
- 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 and parse the output according to the
format.
---
Completion/Unix/Command/_gpg | 65 ++++++++++++++++++++++++++++++++----
1 file changed, 58 insertions(+), 7 deletions(-)
diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index 48a36eff2..c7830bd34 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -206,20 +206,71 @@ 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 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
+ emails+="${public_keys[$j]}"
+ uids+="${public_keys[$i]}"
+ break
+ fi
+ j=$((j + 1))
+ done
+ i=$j
+ fi
+ done
+ _describe -t public-keys 'public key' emails uids
;;
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 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
+ emails+="${secret_keys[$j]}"
+ uids+="${secret_keys[$i]}"
+ 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 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
+ emails+="${public_keys[$j]}"
+ uids+="${public_keys[$i]}"
+ 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