From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23153 invoked from network); 1 Mar 2007 15:45:20 -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:45:20 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 39125 invoked from network); 1 Mar 2007 15:45:15 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Mar 2007 15:45:15 -0000 Received: (qmail 18940 invoked by alias); 1 Mar 2007 15:45:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23202 Received: (qmail 18929 invoked from network); 1 Mar 2007 15:45:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 1 Mar 2007 15:45:11 -0000 Received: (qmail 38802 invoked from network); 1 Mar 2007 15:45:11 -0000 Received: from mailgw1.technion.ac.il (132.68.238.34) by a.mx.sunsite.dk with SMTP; 1 Mar 2007 15:45:03 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgw1.technion.ac.il (Postfix) with ESMTP id 51B73AC575 for ; Thu, 1 Mar 2007 17:45:02 +0200 (IST) X-Virus-Scanned: by amavisd-new at technion.ac.il Received: from mailgw1.technion.ac.il ([127.0.0.1]) by localhost (mailgw1.technion.ac.il [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TIkerLlJFOfS for ; Thu, 1 Mar 2007 17:45:02 +0200 (IST) Received: from fermat.math.technion.ac.il (fermat.math.technion.ac.il [132.68.115.6]) by mailgw1.technion.ac.il (Postfix) with ESMTP id 1DCC3AC0D8 for ; Thu, 1 Mar 2007 17:45:01 +0200 (IST) Received: from fermat.math.technion.ac.il (localhost [127.0.0.1]) by fermat.math.technion.ac.il (8.12.10/8.12.10) with ESMTP id l21FiuSb004089; Thu, 1 Mar 2007 17:44:56 +0200 (IST) Received: (from rl@localhost) by fermat.math.technion.ac.il (8.12.10/8.12.10/Submit) id l21FiuNG004088; Thu, 1 Mar 2007 17:44:56 +0200 (IST) X-Authentication-Warning: fermat.math.technion.ac.il: rl set sender to rl@math.technion.ac.il using -f Date: Thu, 1 Mar 2007 17:44:55 +0200 From: "Zvi Har'El" To: Peter Stephenson Cc: Zsh hackers list Subject: Re: two completion problems. Message-ID: <20070301154455.GB2590@fermat.math.technion.ac.il> References: <20070301141210.GA869@fermat.math.technion.ac.il> <200703011522.l21FMBR7002839@news01.csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200703011522.l21FMBR7002839@news01.csr.com> User-Agent: Mutt/1.4.2.2i Organization: Technion--Israel Institute of Technology Hebrew-Date: 11 Adar 5767 X-PGP-Public-Key: http://www.math.technion.ac.il/~rl/etc/pubkey.html I just noticed that I had a problem with acroread installation: I had both /usr/local/bin/acroread, which was somehow empty and not executible, and later in the path /usr/bin/acroread. While the former file was checked by the completion script, the latter was executed. Fixing that, even the previous function works. But the real question is: why don't use acroread -version instead of trying to read the file? On Thu, 01 Mar 2007 15:22:11 +0000, Peter Stephenson wrote about "Re: two completion problems.": > "Zvi Har'El" wrote: > > I am using the latest CVS have two completion problems: > > 1) acroread completion fails: > > > > ~$ acroread > > _acroread:12: no such file or directory: line > > We search for the path to acrobat in order to check its version number > with the following substitution ($words[1] will be "acroread" or some > modification thereof): > > ${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]} > > This only works if the path is the second word on the first non-empty > line. I get '/usr/local/bin/acroread'. Presumably this is different in > your version. > > However, it's already been confused by that point by the substitution > _acroread_version=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=} > I think that (M) is in the wrong place and this should be: > _acroread_version=${${(M)${(f)"$(<$commands[$words[1]])"}:#ver=*}##ver=} > I haven't checked when this got changed, but the previous version should > never have worked; parameter flags only apply (directly) to the current > level of substitution. > > The following fixes that, and makes the test for whether we can > read the file on the second check safer. (For me this test is > redundant since it refers to the same file we just checked, but > after fixing the version extraction it doesn't get that far.) > > 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:08:34 -0000 > @@ -1,15 +1,25 @@ > #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 [[ $words[1] = */* && -x $words[1] ]]; then > + cmdfile=$words[1] > +elif [[ -x $commands[$words[1]] ]]; then > + cmdfile=$commands[$words[1]] > +fi > + > +if [[ -z $_acroread_version ]]; then > + # 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 -- Dr. Zvi Har'El mailto:rl@math.technion.ac.il Department of Mathematics tel:+972-54-4227607 icq:179294841 Technion - Israel Institute of Technology fax:+972-4-8293388 http://www.math.technion.ac.il/~rl/ Haifa 32000, ISRAEL "If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942) Thursday, 11 Adar 5767, 1 March 2007, 5:42PM