zsh-users
 help / color / mirror / code / Atom feed
* [BUG] zsh gpg completion does not recognize gpg --keyring
@ 2006-07-31  1:26 Mikhail Gusarov
  2006-07-31 10:37 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Mikhail Gusarov @ 2006-07-31  1:26 UTC (permalink / raw)
  To: zsh-users

Hi,

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.

-- 
JID: dottedmag@jabber.dottedmag.net


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] zsh gpg completion does not recognize gpg --keyring
  2006-07-31  1:26 [BUG] zsh gpg completion does not recognize gpg --keyring Mikhail Gusarov
@ 2006-07-31 10:37 ` Peter Stephenson
  2006-07-31 14:08   ` Phil Pennock
  2006-07-31 14:16   ` Mikhail Gusarov
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Stephenson @ 2006-07-31 10:37 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] zsh gpg completion does not recognize gpg --keyring
  2006-07-31 10:37 ` Peter Stephenson
@ 2006-07-31 14:08   ` Phil Pennock
  2006-07-31 14:16   ` Mikhail Gusarov
  1 sibling, 0 replies; 4+ messages in thread
From: Phil Pennock @ 2006-07-31 14:08 UTC (permalink / raw)
  To: zsh-users

On 2006-07-31 at 11:37 +0100, Peter Stephenson wrote:
> 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.

Does it help if I also point out that they've gone one better and gpg
has the --with-colons option, to produce colon-delimited field output
specifically for scripts?  :^)

% gpg --with-colons --list-keys 3903637F 4CE4F655 2>/dev/null
tru:o:0:1153919143:1154174024:3:1:5
pub:u:1024:17:403043153903637F:2004-03-29:2007-03-29::u:Phil Pennock <phil.pennock@example.net>::scaESCA:
uid:u::::2004-09-01::84F2EA62EC251939C5890450B9C30F448B749AAD::Phil Pennock <censored@against.spam>:
uid:u::::2006-06-01::96009DC93F78E37280D361FBF8A2E322F1F22E60::Phil Pennock <censored@against.spam>:
sub:u:1024:16:BD53847773FD5F8D:2004-03-29:2007-03-29:::::e:
pub:u:1024:17:7C34B4E14CE4F655:2001-08-03:2007-09-06::u:Phil Pennock <censored@against.more.spam>::scaESCA:
sub:e:1024:16:467EFEE7212AE5CD:2001-08-03:2003-08-03:::::e:
sub:u:1024:17:B22750EBD749B12B:2004-09-06:2007-09-06:::::s:
sub:u:2048:1:3FA36DE2A4C8B523:2006-06-14:2008-06-13:::::e:

(If you have the PGP keys, you can obviously see the real addresses; I
just blocked them above to limit the spam to some lesser-spammed
addresses.)

       --with-colons
                 Print key listings delimited by colons.  Note that the output
                 will be encoded in UTF-8 regardless of any  --display-charset
                 setting.   This  format  is  useful when GnuPG is called from
                 scripts and other programs as it is  easily  machine  parsed.
                 The  details  of  this  format  are  documented  in  the file
                 doc/DETAILS, which is included in the GnuPG source  distribu-
                 tion.

Regards,
-- 
VISTA: Viruses, Infections, Spyware, Trojans & Adware


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] zsh gpg completion does not recognize gpg --keyring
  2006-07-31 10:37 ` Peter Stephenson
  2006-07-31 14:08   ` Phil Pennock
@ 2006-07-31 14:16   ` Mikhail Gusarov
  1 sibling, 0 replies; 4+ messages in thread
From: Mikhail Gusarov @ 2006-07-31 14:16 UTC (permalink / raw)
  To: zsh-users


You (pws@csr.com) 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.

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

Tested, works fine. Thanks!

-- 
JID: dottedmag@jabber.dottedmag.net


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-31 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-31  1:26 [BUG] zsh gpg completion does not recognize gpg --keyring Mikhail Gusarov
2006-07-31 10:37 ` Peter Stephenson
2006-07-31 14:08   ` Phil Pennock
2006-07-31 14:16   ` Mikhail Gusarov

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).