From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21396 invoked by alias); 1 Feb 2011 19:02:08 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15746 Received: (qmail 28798 invoked from network); 1 Feb 2011 19:02:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.216.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=3adFPrRWHR6wRV3Tlb19op0TACY0DANXbYLi+3RCSaA=; b=aGEo2aXmkyItJVeARE2tEhDmYasPOCZr/KeaM3YtIrkq9Gxo/BpvdZoyCt7aiCsCDY L8kHaLTxK3OjCgcVXwyzE0q4zvsWKmFa0a/fEaC363y3KjpdpYutYCgNdDmscpMFRBd1 n6NV5ASMts5uAZYGoI6K+Dh/XNUX+ZirxydHU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=J23+goGDWwme3PJ3ISMXB0YEls18UqqcppnFpY04TXdTq3N2bHabQJ5PAS1oQfLm9k 5fuZFohKEWrQQcjgmk5/9eBwBPDlcpeLBW/Mec4P0VyOkunZdNdgJ9umA+4uX/mc6k7s saXc3DDe1aZnazwNbJM3ZYyYdI3JwDxGDRgaM= MIME-Version: 1.0 In-Reply-To: <4D4850F7.6060205@gmail.com> References: <4D4850F7.6060205@gmail.com> From: Julien Nicoulaud Date: Tue, 1 Feb 2011 20:01:40 +0100 Message-ID: Subject: Re: Check existence of a program To: Anonymous bin Ich Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=0016e64b03b6d85cab049b3d2a22 --0016e64b03b6d85cab049b3d2a22 Content-Type: text/plain; charset=ISO-8859-1 if type exiftime &>/dev/null; then ... 2011/2/1 Anonymous bin Ich > Hello! > > I am having trouble checking for existence of a program. > > This works: > > % cat working.zsh > #!/bin/zsh > set -x > prog="identify" > path=$(which ${prog}) > % > % ./working.zsh > +./working.zsh:3> prog=identify > +./working.zsh:4> path=+./working.zsh:4> which identify > +./working.zsh:4> path=/usr/bin/identify > % > > But this doesn't: > > % cat notworking.zsh > #!/bin/zsh > set -x > prog="exiftime" > path=$(which ${prog}) > if [[ ${?} -ne 0 ]]; then > prog="identify" > path=$(which ${prog}) > fi > % > % ./notworking.zsh > +./notworking.zsh:3> prog=exiftime > +./notworking.zsh:4> path=+./notworking.zsh:4> which exiftime > +./notworking.zsh:4> path='exiftime not found' > +./notworking.zsh:5> [[ 1 -ne 0 ]] > +./notworking.zsh:6> prog=identify > +./notworking.zsh:7> path=+./notworking.zsh:7> which identify > +./notworking.zsh:7> path='identify not found' > % > > Any idea? > --0016e64b03b6d85cab049b3d2a22--