csh question

scw%ucla-locus at cepu.UUCP scw%ucla-locus at cepu.UUCP
Sun Feb 26 03:53:00 AEST 1984


From:  Steve Woods <cepu!scw at ucla-locus>


	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");
					}
    ----------------------

    when you run it, you get the "shouldn't get here" message printed out.
    Does anyone know why? 

Because you should, look at the ~equivalent 'c' program. the thing is that
the endif is much like a closing brace '}'.



More information about the Comp.unix.wizards mailing list