From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23920 invoked from network); 31 Jul 2006 10:44:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Jul 2006 10:44:34 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 15430 invoked from network); 31 Jul 2006 10:44:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Jul 2006 10:44:26 -0000 Received: (qmail 22985 invoked by alias); 31 Jul 2006 10:44:16 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10564 Received: (qmail 22976 invoked from network); 31 Jul 2006 10:44:15 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 31 Jul 2006 10:44:15 -0000 Received: (qmail 14108 invoked from network); 31 Jul 2006 10:44:15 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 31 Jul 2006 10:44:11 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly26c.srv.mailcontrol.com (MailControl) with ESMTP id k6VAhRVB003122 for ; Mon, 31 Jul 2006 11:44:03 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Mon, 31 Jul 2006 11:37:34 +0100 Date: Mon, 31 Jul 2006 11:37:32 +0100 From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: [BUG] zsh gpg completion does not recognize gpg --keyring Message-Id: <20060731113732.4c595080.pws@csr.com> In-Reply-To: <87zmeqr2d4.fsf@vertex.dottedmag.net> References: <87zmeqr2d4.fsf@vertex.dottedmag.net> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.6 (GTK+ 2.6.7; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 31 Jul 2006 10:37:34.0448 (UTC) FILETIME=[55800700:01C6B48D] X-Scanned-By: MailControl A-07-00-10 (www.mailcontrol.com) on 10.67.0.136 Mikhail Gusarov 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 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