Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!ucscc!argv@ucb-vax.ARPA From: argv@ucb-vax.ARPA Newsgroups: net.unix-wizards Subject: Yet even MORE Csh Quirks Message-ID: <10032@brl-tgr.ARPA> Date: Thu, 18-Apr-85 08:09:37 EST Article-I.D.: brl-tgr.10032 Posted: Thu Apr 18 08:09:37 1985 Date-Received: Sat, 20-Apr-85 08:32:18 EST Sender: news@brl-tgr.ARPA Lines: 42 (Yell at me if you're sick of them) This is the case of the matching "if" statements with their respective "endif" statements. It seems that "endif"'s don't know who they are ending. Exibit A: #!/bin/csh -f @ count = 0 if($#argv == 2) then echo hi there if( 1 ) then # this statement if obviously a no-op. @ count++ # count should be 1 echo true endif echo hi there again @ count++ # count should be 2 endif echo count = $count if argv is NOT 2, then $count should be 0, right?! else count should be 2... but in ANY event, count should NEVER be 1. Also, you should either see, "hi there" AND "hi there again" or NEITHER, am I right? The fault lies in the fact that you can't have nested if statements. The first endif it sees ends ALL ifs, not just the one associated with it. If this is the case, why aren't I getting syntax errors for the extra (non-matching) endif? Dan Heller (aka Frank) ------------------------------------------------------------------------------ UCSC Computing Center Consultant (Looking for a UNIX/C hacking Job - nudge nudge wink wink) UUCP: ucbvax!ucscc!argv {ihnp4,sun,cbosgd,decwrl}!qubix!ucscc!argv ARPA: argv%ucscc.uucp@ucb-vax.arpa CSnet: c.argv@ucsc.csnet (say no more, say no more) ------------------------------------------------------------------------------- p.s. csh man entry doesn't address this (at least OURS doesn't).