[comp.unix.questions] FUBAR: Undefined variable.

jdpeek@rodan.acs.syr.edu (Jerry Peek) (08/06/90)

Thanks for the help on my question about csh quoting weirdness...

Here's one about variables.  I want to write a test that is true when
a variable is not set, OR when it is not set to a certain value.
The test I want looks like this:
	if ( (!$?var) || ($var != value) ) then
		# do stuff 
		...
	endif

But if var isn't set, csh says:
	var: Undefined variable.
and the script aborts.

I wrote an ugly mess of nested if's that patched around the problem
by putting the ($var != value) on a separate line.  But there's gotta
be a better way.  Can I tell csh not to treat an unset variable as an
error (in other words, to act like sh)?  I didn't see it in TFM.  Thanks.

--Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY
  jdpeek@rodan.acs.syr.edu, JDPEEK@SUNRISE.BITNET        +1 315 443-3995

boyd@necisa.ho.necisa.oz (Boyd Roberts) (08/08/90)

FUBAR == Failed UniBus Address Register :-)


Boyd Roberts			boyd@necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''