Date: Thu, 28 Jun 2001 21:42:20 -0700 From: Dave Tweten <tweten@nas.nasa.gov> To: Pete Fritchman <petef@databits.net> Cc: freebsd-doc@freebsd.org Subject: Re: Fw: Re: Bourne Shell Syntax Wierdness Message-ID: <200106290442.f5T4gLu02151@gilmore.nas.nasa.gov>
index | next in thread | raw e-mail
petef@databits.net said:
>you first take 'true || true' -- you end up with true.
According to the man page, "||" is NOT "or". Instead it is an operator that
causes the command to its right to be executed only if the simple command to
its left fails. Therefore, 'true || true' means "continue without executing
the rightmost "true".
The (slightly dated) copy of POSIX.2 I have in my office actually calls the
following an "OR List," but says
command1 [ || command2 ] ...
means:
"First, command1 shall be executed. If its exit status is nonzero,
command2 xhall be executed, and so on until a command has a zero
exit status or there are no more commands left to execute."
Similarly, it calls the following an "AND List," but says
command1 [ && command2 ] ...
means:
"First, command1 shall be executed. If its exit status is zero,
command2 shall be executed, and so on until a command has a nonzero
exit status or there are no more commands left to execute. The
comnmands shall be expanded only if they are executed."
Curiously, POSIX says nothing about a list containing both operators.
--
M/S 258-5 | 1024-bit PGP fingerprint: | tweten@nas.nasa.gov
NASA Ames Research Center | 41 B0 89 0A 8F 94 6C 59 | (650) 604-4416
Moffett Field, CA 94035-1000 | 7C 80 10 20 25 C7 2F E6 | FAX: (650) 604-4377
We each earn what freedom of speech we defend for those who most offend us.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106290442.f5T4gLu02151>
