csh, exit, &&, || (was Re: exit(-1), 0 is sometimes magic)

Chris Torek chris at mimsy.UUCP
Sun Jan 24 14:43:36 AEST 1988

(I overrode Rich's followup-to header, since there are buggy csh's out
In article <310 at fig.bbn.com> rsalz at bbn.com (Rich Salz) writes:
>The use of && and || in csh is the opposite of that in /bin/sh.
>	/bin/sh -c "/bin/test -d foo || mkdir foo"
>Means if the foo directory doesn't exist, make it. ...
>	/bin/csh -c "/bin/test -d foo || mkdir foo"
>will never make the directory, or mkdir will spit if it already exists.


Sorry, contestant number 3.


Old versions of the C shell did indeed have this bug.  It has been
fixed for years.  If your C shell does this, complain to your vendor
(or upgrade from 3BSD!).  I believe the documentation has always
claimed that the C shell's `&&' and `||' constructs work in the
same way as the Bourne shell's.
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris

More information about the Comp.lang.c mailing list