zsh-users
 help / color / mirror / code / Atom feed
* Check existence of a program
@ 2011-02-01 18:29 Anonymous bin Ich
  2011-02-01 19:01 ` Julien Nicoulaud
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Anonymous bin Ich @ 2011-02-01 18:29 UTC (permalink / raw)
  To: zsh-users

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?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-01 21:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 18:29 Check existence of a program Anonymous bin Ich
2011-02-01 19:01 ` Julien Nicoulaud
2011-02-01 19:16 ` Benjamin R. Haskell
2011-02-01 19:16 ` Jérémie Roquet
2011-02-01 20:16 ` Bart Schaefer
2011-02-01 21:39 ` Atom Smasher

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).