From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22057 invoked from network); 25 Apr 2005 13:00:34 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 25 Apr 2005 13:00:34 -0000 Received: (qmail 77353 invoked from network); 25 Apr 2005 13:00:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Apr 2005 13:00:26 -0000 Received: (qmail 7378 invoked by alias); 25 Apr 2005 13:00:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21188 Received: (qmail 7325 invoked from network); 25 Apr 2005 13:00:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 25 Apr 2005 13:00:22 -0000 Received: (qmail 77015 invoked from network); 25 Apr 2005 13:00:22 -0000 Received: from pat.uio.no (129.240.130.16) by a.mx.sunsite.dk with SMTP; 25 Apr 2005 13:00:12 -0000 Received: from mail-mx4.uio.no ([129.240.10.45]) by pat.uio.no with esmtp (Exim 4.43) id 1DQ3C7-0004ek-FX for zsh-workers@sunsite.dk; Mon, 25 Apr 2005 15:00:11 +0200 Received: from 115.80-203-46.nextgentel.com ([80.203.46.115] helo=fox.venod.com) by mail-mx4.uio.no with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.43) id 1DQ3C3-0003Na-Qr for zsh-workers@sunsite.dk; Mon, 25 Apr 2005 15:00:07 +0200 Received: (qmail 5022 invoked by uid 1000); 25 Apr 2005 13:00:02 -0000 Date: Mon, 25 Apr 2005 15:00:02 +0200 From: Haakon Riiser To: Zsh hackers list Subject: Re: Updated _acroread completer Message-ID: <20050425130002.GA3137@fox> Mail-Followup-To: Zsh hackers list References: <20050414134703.GA7862@s> <20050415111158.GA1709@s> <7344.1114415007@trentino.groupinfra.com> <20050425084156.GA483@fox> <200504250939.j3P9dqih005645@news01.csr.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline In-Reply-To: <200504250939.j3P9dqih005645@news01.csr.com> User-Agent: Mutt/1.5.9i X-UiO-Spam-info: not spam, SpamAssassin (score=-3.892, required 12, autolearn=disabled, AWL 1.06, FORGED_RCVD_HELO 0.05, UIO_MAIL_IS_INTERNAL -5.00) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline [Peter Stephenson] > Haakon Riiser wrote: > > So I'll just have to resolve the symlink using readlink. I assume > > the most portable way to do this is perl, unless there is a way > > to make zsh expand the link itself. I have attached a version that > > does this. Should handle any level of symbolic links that point to > > new symbolic links. > > You can use the zsh/stat library. > > zmodload -i zsh/stat > stat -A ln +link ~/perforce > print $ln[1] > /pws/perforce Thanks, but I did away with that completely. There's really no need to think about symblic links and the version file when the version number actually is embedded in the ACROREAD-PREFIX/bin/acroread script. Attached to this mail is the latest version that only runs acroread -help to determine the patch to the real executable when the version number was not found directly in $command[$words[1]]. By the way, it uses "sed -n 's/^ver=//p' FILE" to extract the version. Is it preferable to use zsh's own string functions to do this? The code tends to become quite hard to read, and I usually need to spend much more time writing it than when I use sed or awk. -- Haakon --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=_acroread #compdef acroread local curcontext="$curcontext" state line # Try extracting the version number directly from the executable. # (This will fail if the executable is a wrapper script for acroread.) local ver=$(sed -n 's/^ver=//p' $commands[$words[1]] 2>/dev/null) [[ -n $ver ]] && _acroread_version=$ver if [[ -z $_acroread_version ]]; then local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]} _acroread_version=$(sed -n 's/^ver=//p' "$acropath" 2>/dev/null) fi if [[ $_acroread_version == 7.* ]]; then _arguments -C \ '--display=:X display:_x_display' \ '--screen=:X screen (overrides the screen part of DISPLAY)' \ --sync \ '-geometry:[x][{+|-}{+|-}]' \ -help \ -iconic \ '*-setenv:=' \ -tempFile \ '-tempFileTitle:title' \ -openInNewWindow \ -version \ '-visual:X visual:_x_visual' \ '-toPostScript:*::PostScript conversion options:= ->tops' \ '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return [[ -n "$state" ]] && _arguments \ '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \ -binary \ '-start:integer' \ '-end:integer' \ -optimizeForSpeed \ -landscape \ -reverse \ '(-even)-odd' \ '(-odd)-even' \ -commentsOff \ -annotsOff \ '(-level3)-level2' \ '(-level2)-level3' \ -printerhalftones \ -saveVM \ '-scale:integer' \ -shrink \ -expand \ '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \ '-transQuality:transparency flattening level:(1 2 3 4 5)' \ '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return else _x_arguments -C \ -help \ -helpall \ \*-iconic \ \*+iconic \ '-name:application name:_x_name' \ '*-setenv:=' \ -tempFile \ '-tempFileTitle:title' \ '(+useFrontEndProgram)-useFrontEndProgram' \ '(-useFrontEndProgram)+useFrontEndProgram' \ '-visual:X visual:_x_visual' \ '-xrm:X resource specification:_x_resource' \ '-toPostScript:*::PostScript conversion options:= ->tops' \ '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return [[ -n "$state" ]] && _arguments \ '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \ -binary \ '-start:integer' \ '-end:integer' \ -optimizeForSpeed \ -landscape \ -reverse \ '(-even)-odd' \ '(-odd)-even' \ -commentsOff \ '(-level2 -level3)-level1' \ '(-level1 -level3)-level2' \ '(-level1 -level2)-level3' \ -printerhalftones \ -saveVM \ '-scale:integer' \ -shrink \ '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \ '-transQuality:transparency flattening level:(1 2 3 4 5)' \ '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return fi return 1 --Nq2Wo0NMKNjxTN9z--