zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: [BUG] zsh gpg completion does not recognize gpg --keyring
Date: Mon, 31 Jul 2006 11:37:32 +0100	[thread overview]
Message-ID: <20060731113732.4c595080.pws@csr.com> (raw)
In-Reply-To: <87zmeqr2d4.fsf@vertex.dottedmag.net>

Mikhail Gusarov <dottedmag@dottedmag.net> wrote:
> Autocomplete in commang 'gpg --no-default-keyring --keyring
> /some/key/ring' gives me userids from my default keyring (~/.gnupg),
> not from the specified in the command line.

I think the following fixes it, but I don't have a gpg setup to use for
testing, so I haven't confirmed the effect (though I did test the code I
added).  Luckily, somebody cleverly wrote gpg with just the structure
needed for this addition.

Index: Completion/Unix/Command/_gpg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_gpg,v
retrieving revision 1.5
diff -u -r1.5 _gpg
--- Completion/Unix/Command/_gpg	10 Jul 2005 12:03:18 -0000	1.5
+++ Completion/Unix/Command/_gpg	31 Jul 2006 10:36:36 -0000
@@ -139,18 +139,35 @@
   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
 


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


  reply	other threads:[~2006-07-31 10:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-31  1:26 Mikhail Gusarov
2006-07-31 10:37 ` Peter Stephenson [this message]
2006-07-31 14:08   ` Phil Pennock
2006-07-31 14:16   ` Mikhail Gusarov

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=20060731113732.4c595080.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /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).