Subject: Strange shell problem
To: None <netbsd-help@netbsd.org>
From: Chris Lloyd <strawberry@toth.org.uk>
List: netbsd-help
Date: 11/18/2002 14:37:18
Hiya,

I'm having a problem with a bit of shell script, the problem only seems to
exhibit itself on NetBSD.

where=`which notaprogram`; if [ $? -gt 0 ]; then echo "Install it"; fi

I'm trying to work out if an executable exists, to be used later on in the
script, and warn the user if they haven't got it installed.

Problem is, on my netbsd machine, $? seems to be being set to 0 by which.
It doesn't get set to 0 on linux or openbsd. Is being set to 0 the correct
behaviour or not?

If anyone knows a nicer way of checking to see if a program exists, then 
that'd be good too. (I don't really want to use if [ -x notaprogram ] because
that prints on the shells stderr in an ugly way.

Thanks, 

 - Chris

--
strawberry@toth.org.uk
http://www.toth.org.uk/~strawberry