Subject: Re: Strange shell problem
To: None <netbsd-help@netbsd.org>
From: David S. <davids@idiom.com>
List: netbsd-help
Date: 11/18/2002 14:07:05
> 
> 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?

'which' on NetBSD is a c-shell script.  The part relevant to this
problem is

	if ( ! $?found ) then
		echo no $arg in $path
	endif

You can easily add an "exit 1" there after the "echo ...' statement
to make it do what you want.

Or, you might try 'whereis'.

David S.

>