Help needed with conditional statement for alias in csh

Per Hedeland per at erix.ericsson.se
Fri Sep 21 19:36:45 AEST 1990


In article <1990Sep20.090627.20515 at Neon.Stanford.EDU>,
dkeisen at Gang-of-Four.Stanford.EDU (Dave Eisen) writes:
|> Speak for your own C-shell. 

I spoke for *the* C-shell, as found in the BSD distribution (I wouldn't
dream of claiming any ownership:-). If someone distributes a shell where the
meaning of && and || is reversed, it certainly isn't the C-shell, just as a
compiler for a language that reverses the meaning of those two isn't a C
compiler.

|> In SCO Xenix, the C-shell thinks it really is C:
|> 
|> 	test -s /usr/spool/mail/miller 
|> 
|> returns 0 (assuming the file is nonempty) so the C-shell doesn't 
|> evaluate the second half of the conditional expression.

I don't buy the "really is C" "justification" - I think that the proper
point of view is that in C, as in Bourne shell and C-shell, the expression
following && is evaluated if the preceding expression is *true* - the fact
that C (and the C-shell in 'if' etc) happens to define "true" as non-zero
and the shells and utilities define it as (return code) zero may be
confusing but is nonetheless irrelevant.

Of course, the csh man page doesn't talk about "true" in this context, but
rather "fails" and "succeeds" - surely not even SCO thinks that return code
zero from a Unix program is a failure indication?

--Per Hedeland
per at erix.ericsson.se  or
per%erix.ericsson.se at uunet.uu.net  or
...uunet!erix.ericsson.se!per



More information about the Comp.unix.shell mailing list