Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1+some 2/3/84; site dual.UUCP
Path: utzoo!linus!vaxine!wjh12!genrad!grkermit!masscomp!clyde!burl!ulysses!mhuxl!ihnp4!dual!fair
From: fair@dual.UUCP
Newsgroups: net.unix-wizards
Subject: Re: re: csh question - (nf)
Message-ID: <317@dual.UUCP>
Date: Tue, 28-Feb-84 22:04:43 EST
Article-I.D.: dual.317
Posted: Tue Feb 28 22:04:43 1984
Date-Received: Fri, 2-Mar-84 00:15:09 EST
References: <2640@fortune.UUCP>
Organization: Dual Systems, Berkeley, CA
Lines: 49

[RAID]
	I'm having trouble with nesting of csh "if-else-endif". In the following

    ----------------------
    #! /bin/csh				{
    set x=1				    x=1;
    if($x == 1) then			    if(x == 1){
	    set y=2			        y=2;
    else				    }else{
	    if($y == 2) then		        if(y == 2){
		    echo "line 1"		    printf("line 1");
	    else			        }else{
		    echo "line 2"		    printf("line 2");
	    endif			        }
	    echo "shouldn't get here"	    printf("shouldn't get here");
    endif				    }
    echo "finished"			printf("finished");
					}
    ----------------------

You problem is due to the fact that only one 'endif' is needed.  The 
documentation on the csh states:

	if (expr) then
		....
	else if (expr2) then
		....
	else
		....
	endif

	Any number of else-if pairs are possible; only one endif is needed.


	Richard McNeal
UUCP:	{sri-unix,amd70,hpda,harpo,ihnp4,allegra}!fortune!mcneal
DDD:	(415)595-8444
USPS:	Fortune Systems Corp, 101 Twin Dolphins Drive, Redwood City, CA 94065
----

It should also be noted that csh is particular about spacing, so there should
be a space between the `if' and the first paren. I believe there was even a
bug associated with nested if's in Csh reported some time back...

	Erik E. Fair

	dual!fair@BERKELEY.ARPA
	{ihnp4,ucbvax,cbosgd,decwrl,amd70,fortune,zehntel}!dual!fair
	Dual Systems Corporation, Berkeley, California