Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Check existence of a program
- X-seq: zsh-users 15748
- From: Jérémie Roquet <arkanosis@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Check existence of a program
- Date: Tue, 1 Feb 2011 20:16:32 +0100
- 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=
- In-reply-to: <4D4850F7.6060205@gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4D4850F7.6060205@gmail.com>
Sorry for the double-reply, I missed the list.
2011/2/1 Anonymous bin Ich <ichbinanon@xxxxxxxxx>:
> 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?
>
You have overridden $path :-)
--
Jérémie
Messages sorted by:
Reverse Date,
Date,
Thread,
Author