FUBAR: Undefined variable. (csh)
Jerry Peek
jdpeek at rodan.acs.syr.edu
Tue Aug 7 02:56:44 AEST 1990
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 at rodan.acs.syr.edu, JDPEEK at SUNRISE.BITNET +1 315 443-3995
More information about the Comp.unix.questions
mailing list