csh question - (nf)

mcneal at fortune.UUCP mcneal at fortune.UUCP
Wed Feb 29 06:19:50 AEST 1984


#R:sri-arpa:-1694400:fortune:11600069:000:1001
fortune!mcneal    Feb 28 10:14:00 1984



	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



More information about the Comp.unix.wizards mailing list