From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16059 invoked by alias); 1 Feb 2011 19:41:22 -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: 15748 Received: (qmail 5477 invoked from network); 1 Feb 2011 19:41:21 -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,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.215.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:content-type:content-transfer-encoding; bh=64zzcknLJuZapGp56p89/ZVL7XazK5OOpxhB1pWA644=; b=Il/QCfald1o4wXWacaTkCbWxmo7C04Tf2sxKY8dfOt2lggxKt4iOGLBX4JQN6JLCqi OV8aTBg5akMru8epz35lfMDEaEyxuNrWTees5nhgK/UFVR9atn5Ma3ZRA381mYpo49vH 6rd3z6/6Mat5bS1Wo7Z447+r6LG6NqU9UeArY= 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 :content-type:content-transfer-encoding; b=wYurQekuBxncDVvhHxSteiKI4/IgB3Apdb2kEGDXmSgD5nJWn7lPxFmq8yxuNVTjr8 WAqsg+sFgYrXVuwbHO1BBGSlFfJBk+y2oupgH7nSvcd9L+27LL5JUzPS28Eq4nC/wVXO 3KMhQ1GT+OKS+c0N13xs5tssWqdjBaoMv/9eI= MIME-Version: 1.0 In-Reply-To: <4D4850F7.6060205@gmail.com> References: <4D4850F7.6060205@gmail.com> From: =?UTF-8?B?SsOpcsOpbWllIFJvcXVldA==?= Date: Tue, 1 Feb 2011 20:16:32 +0100 Message-ID: Subject: Re: Check existence of a program To: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry for the double-reply, I missed the list. 2011/2/1 Anonymous bin Ich : > I am having trouble checking for existence of a program. > > This works: > > % cat working.zsh > #!/bin/zsh > set -x > prog=3D"identify" > path=3D$(which ${prog}) > % > % ./working.zsh > +./working.zsh:3> prog=3Didentify > +./working.zsh:4> path=3D+./working.zsh:4> which identify > +./working.zsh:4> path=3D/usr/bin/identify > % > > But this doesn't: > > % cat notworking.zsh > #!/bin/zsh > set -x > prog=3D"exiftime" > path=3D$(which ${prog}) > if [[ ${?} -ne 0 ]]; then > =C2=A0 =C2=A0prog=3D"identify" > =C2=A0 =C2=A0path=3D$(which ${prog}) > fi > % > % ./notworking.zsh > +./notworking.zsh:3> prog=3Dexiftime > +./notworking.zsh:4> path=3D+./notworking.zsh:4> which exiftime > +./notworking.zsh:4> path=3D'exiftime not found' > +./notworking.zsh:5> [[ 1 -ne 0 ]] > +./notworking.zsh:6> prog=3Didentify > +./notworking.zsh:7> path=3D+./notworking.zsh:7> which identify > +./notworking.zsh:7> path=3D'identify not found' > % > > Any idea? > You have overridden $path :-) --=20 J=C3=A9r=C3=A9mie