Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Check existence of a program
- X-seq: zsh-users 15745
- From: Anonymous bin Ich <ichbinanon@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Check existence of a program
- Date: Tue, 01 Feb 2011 23:59:11 +0530
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:content-type:content-transfer-encoding; bh=9rhKDyz7YfsU/ijcyXHMnw5/oFKFpogL5YBcsLjaNtg=; b=HvkTtS3i2i2Azy4FXJubMdN6KpoRxRLgRAUS20YFHv4YxBxLcVFMr1aiw8QnrQ4kHY 3FTafzO1JwGgCYTDZ+zqrXwjYiC4wC4r0IkSc2TONYQaypR2mtzHBaxtz6YgUp76FcsB 2yBtvH7k4K7CG6NZlFO1Q85LQV5Z2CD9UcThM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=dG4On8ckoKIeHQfq36zY38c6ZhwOPktZJrjkA06cyPUDzATgMP2EH3XaBSsRQuxj2G KV3icApY3xpRAIKl+00u1K8IPYkLhmSm/Cvnd/BpkBy+Y55I7UjtYZVFEwU/XucFwAVs Mc69wePnRElKitOSIp5aEitUExIx43lI5R5z8=
- 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
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