From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28710 invoked from network); 1 Mar 2007 15:51:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.8 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Mar 2007 15:51:50 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 48584 invoked from network); 1 Mar 2007 15:51:44 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Mar 2007 15:51:44 -0000 Received: (qmail 21376 invoked by alias); 1 Mar 2007 15:51:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23203 Received: (qmail 21367 invoked from network); 1 Mar 2007 15:51:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 1 Mar 2007 15:51:39 -0000 Received: (qmail 47932 invoked from network); 1 Mar 2007 15:51:39 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 1 Mar 2007 15:51:32 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly43d.srv.mailcontrol.com (MailControl) with ESMTP id l21FpUcM002054 for ; Thu, 1 Mar 2007 15:51:31 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Thu, 1 Mar 2007 15:50:35 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.8/8.13.4) with ESMTP id l21FoV9v003473 for ; Thu, 1 Mar 2007 15:50:31 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.13.8/8.13.8/Submit) with ESMTP id l21FoVOw003470 for ; Thu, 1 Mar 2007 15:50:31 GMT Message-Id: <200703011550.l21FoVOw003470@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Zsh hackers list Subject: Re: two completion problems. In-reply-to: <20070301154455.GB2590@fermat.math.technion.ac.il> References: <20070301141210.GA869@fermat.math.technion.ac.il> <200703011522.l21FMBR7002839@news01.csr.com> <20070301154455.GB2590@fermat.math.technion.ac.il> Comments: In-reply-to "Zvi Har'El" message dated "Thu, 01 Mar 2007 17:44:55 +0200." Date: Thu, 01 Mar 2007 15:50:31 +0000 From: Peter Stephenson X-OriginalArrivalTime: 01 Mar 2007 15:50:35.0821 (UTC) FILETIME=[5A0EDDD0:01C75C19] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-06-80 (www.mailcontrol.com) on 10.68.0.153 "Zvi Har'El" wrote: > But the real question is: why don't use acroread -version > instead of trying to read the file? Indeed, I've folded that in as the default. Index: Completion/X/Command/_acroread =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_acroread,v retrieving revision 1.6 diff -u -r1.6 _acroread --- Completion/X/Command/_acroread 26 Mar 2006 15:15:10 -0000 1.6 +++ Completion/X/Command/_acroread 1 Mar 2007 15:49:15 -0000 @@ -1,15 +1,29 @@ #compdef acroread local curcontext="$curcontext" state line +local cmdfile -# Try extracting the version number directly from the executable. -# (This will fail if the executable is a wrapper script for acroread.) -local ver=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=} -[[ -n $ver ]] && _acroread_version=$ver - -if (( ! $+_acroread_version )); then - local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]} - _acroread_version=${${${(Mf)"$(<$acropath)"}:#ver=*}##ver=} +if [[ -z $_acroread_version ]]; then + _acroread_version="$($words[1] -version 2>/dev/null)" +fi + +if [[ -z $_acroread_version ]]; then + if [[ $words[1] = */* && -x $words[1] ]]; then + cmdfile=$words[1] + elif [[ -x $commands[$words[1]] ]]; then + cmdfile=$commands[$words[1]] + fi + + # Try extracting the version number directly from the executable. + # (This will fail if the executable is a wrapper script for acroread.) + _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=} + + if [[ -z $_acroread_version ]]; then + local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]} + if [[ -r $acropath ]]; then + _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=} + fi + fi fi if [[ $_acroread_version == 7.* ]]; then -- 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 To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview