possible problem in csh if/then/endif
Bill Carson
brighton at pixar.UUCP
Fri Oct 3 19:10:58 AEST 1986
consider this: (as run on a virgin 4.3BSD csh (vax))
% cat -n test.sh
1 #! /bin/csh -fx
2
3 set machine = string
4 set host = string
5 set foo = bar
6
7 if ( $machine !~ $host ) then
8 if ( $foo =~ bar ) then
9 echo dummy if statement
10 endif
11 echo this should not happen
12 else
13 echo this should happen
14 endif
running this works as you would expect, it will echo "this should happen"
Ok, on line 8, if you remove the space between the 'if' and the '(' so that
it looks like this:
8 if( $foo =~ bar ) then
then it will echo "this should not happen". I know this sounds confusing,
but extract the shell script, play with it, and you'll see what I mean.
This is most annoying, because I've just been bitten by this bug in our
backup scripts. Joe Bob says "pull your hair out"
Can anyone provide an explanation?
-Bill ...!{ucbvax,sun}!pixar!brighton
More information about the Comp.unix.wizards
mailing list