Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!rutgers!sri-spam!nike!ucbcad!ucbvax!ucsfcgl!pixar!brighton From: brighton@pixar.UUCP (Bill Carson) Newsgroups: net.unix-wizards Subject: possible problem in csh if/then/endif Message-ID: <113@pixar.UUCP> Date: Fri, 3-Oct-86 05:10:58 EDT Article-I.D.: pixar.113 Posted: Fri Oct 3 05:10:58 1986 Date-Received: Sat, 4-Oct-86 11:09:37 EDT Reply-To: brighton@pixar.UUCP (Bill Carson) Followup-To: net.unix-wizards Distribution: net Organization: Pixar -- Marin County, California Lines: 34 Keywords: csh parser 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