Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Check existence of a program
- X-seq: zsh-users 15746
- From: Julien Nicoulaud <julien.nicoulaud@xxxxxxxxx>
- To: Anonymous bin Ich <ichbinanon@xxxxxxxxx>
- Subject: Re: Check existence of a program
- Date: Tue, 1 Feb 2011 20:01:40 +0100
- Cc: zsh-users@xxxxxxx
- 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=
- 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>
if type exiftime &>/dev/null; then ...
2011/2/1 Anonymous bin Ich <ichbinanon@xxxxxxxxx>
> 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?
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author