about summary refs log tree commit diff
path: root/Completion/Unix/Command/_gpg
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-08-01 11:31:22 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-08-01 11:31:22 +0000
commitf34e095f4bcf47168275124be196a2a1c7be98ed (patch)
treed546967d0dff2d8dd7cb8c975c8178669f1ceb1e /Completion/Unix/Command/_gpg
parente7944e7606442684578fb2d31f8e811ece0b1403 (diff)
downloadzsh-f34e095f4bcf47168275124be196a2a1c7be98ed.tar.gz
zsh-f34e095f4bcf47168275124be196a2a1c7be98ed.tar.xz
zsh-f34e095f4bcf47168275124be196a2a1c7be98ed.zip
users/10564: _gpg key ring fix
Diffstat (limited to 'Completion/Unix/Command/_gpg')
-rw-r--r--Completion/Unix/Command/_gpg23
1 files changed, 20 insertions, 3 deletions
diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index 04b6f714c..a4680a0c2 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -139,18 +139,35 @@ if [[ $state = args ]]; then
   fi
 fi
 
+# We need to keep some arguments to get a consistent list of keys
+# etc.
+local -a needed
+integer krind=${words[(I)--keyring(|=*)]}
+needed=(${words[(r)--no-default-keyring]})
+if (( krind )); then
+  # We have a --keyring option.  We can't be completing its
+  # argument because that was handled above, so it must be complete.
+  if [[ $words[krind] = --keyring ]]; then
+    if [[ -n $words[krind+1] ]]; then
+      needed+=(--keyring=$words[krind+1])
+    fi
+  else
+    needed+=($words[krind])
+  fi
+fi
+
 case "$state" in
   public-keys)
     _wanted public-keys expl 'public key' \
-	compadd ${${(Mo)$(_call_program public-keys gpg --list-keys 2>/dev/null):%<*>}//(<|>)/} && return
+	compadd ${${(Mo)$(_call_program public-keys gpg $needed --list-keys 2>/dev/null):%<*>}//(<|>)/} && return
   ;;
   secret-keys)
     _wanted secret-keys expl 'secret key' compadd \
-	${${(Mo)$(_call_program secret-keys gpg --list-secret-keys 2>/dev/null):%<*>}//(<|>)/} && return
+	${${(Mo)$(_call_program secret-keys gpg $needed --list-secret-keys 2>/dev/null):%<*>}//(<|>)/} && return
   ;;
   ciphers)
     _wanted ciphers expl cipher compadd \
-        ${${(s.,.)${(M)${(f)"$(_call_program ciphers gpg --version)"}:#Cipher*}#*:}# } && return
+        ${${(s.,.)${(M)${(f)"$(_call_program ciphers gpg $needed --version)"}:#Cipher*}#*:}# } && return
   ;;
 esac