nested if's in csh

eric%cit-vax at sri-unix.UUCP eric%cit-vax at sri-unix.UUCP
Tue Feb 28 08:43:43 AEST 1984


From:  Eric Holstege <eric at cit-vax>

The following shell script, when run with the four permutations of inputs
t 0 0
t 1 0
t 0 1
t 1 1
works correctly in all cases.

#! /bin/csh -f
set a = $1
set b = $2
if ( $a ) then
    if ( $b ) then
	echo a and b
    else
	echo a and not b
    endif
else
    if ( $b ) then
	echo not a, but b
    else
	echo neither a nor b
    endif
endif

However, if spaces are left out between the "if" and the "(", it no
longer works correctly. Thus the space appears to be the key. This seems
to be a bug.

		    * Eric Holstege  Caltech, Pasadena, CA.
		    * eric at cit-vax



More information about the Comp.unix.wizards mailing list