summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Misbakh-Soloviov <msva@users.noreply.github.com>2025-02-19 17:20:14 +0700
committerOliver Kiddle <opk@zsh.org>2025-02-27 16:07:36 +0100
commit1818323f451f426f20ca47c50e8fc63824578479 (patch)
treecc9742368eb8e3adf8d007daa681509b529804db
parente160cf85f05c3106189edf2158146b9f522d1f1c (diff)
downloadzsh-1818323f451f426f20ca47c50e8fc63824578479.tar.gz
zsh-1818323f451f426f20ca47c50e8fc63824578479.zip
github #129: fix _gpg completion
1) As for now, `--local-user` completion is irrelevant: it completes system users, while gpg expects private keys IDs 2) `secret-keys` completion was also broken and completed nothing. The reason of that to happen was in that fact that it assumed `uid` token would be next after `fpr` (same as it do in public-keys completion), while in current gnupg versions there is at least `grp` token, and potentially can be others. So, instead i+=2 I made `until "uid"` loop.
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Unix/Command/_gpg8
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 80745557f..cd00105cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2025-02-27 Oliver Kiddle <opk@zsh.org>
+ * github #129: Vadim Misbakh-Soloviov:
+ Completion/Unix/Command/_gpg: fix _gpg completion
+
* 53378: Doc/Zsh/builtins.yo, Src/Builtins/rlimits.c, configure.ac:
support new pipebuf resource limit on FreeBSD
diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index 2161d2d24..ea0a452f2 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -29,7 +29,7 @@ fi
'(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cipher only]'
'(-s --sign)'{-s,--sign}'[make a signature]'
'*'{-r+,--recipient}'[specify user to encrypt for]:recipient:->public-keys'
- '(-u --local-user)'{-u+,--local-user}'[use name as the user ID to sign]:user attachment:_users'
+ '(-u --local-user)'{-u+,--local-user}'[use name as the user ID to sign]:key:->secret-keys'
'(-o --output)'{-o+,--output}'[write output to file]:output file:_files'
'(-h --help)'{-h,--help}'[display usage information]'
'--version[print info on program version and supported algorithms]'
@@ -238,7 +238,11 @@ case "$state" in
parts=("${(@s.:.)secret_keys_lines[$i]}")
if [[ ${parts[1]} == "fpr" ]]; then
current_uid="${parts[10]}"
- i=$((i + 1))
+ until [[ "${${(@s.:.)secret_keys_lines[$i]}[1]}" == "uid" ]] || [[ "${i}" -ge "${#secret_keys_lines[@]}" ]]; do
+ # it can be "grp" or other tokens.
+ # Let's iterate until we found "uid" or face an end of secret keys array
+ i=$((i + 1))
+ done
parts=("${(@s.:.)secret_keys_lines[$i]}")
while [[ ${parts[1]} == "uid" ]]; do
uids+=("${current_uid}")