On Fri, Oct 8, 2010 at 4:12 PM, Philip Guenther <[email protected]>
wrote:
> On Fri, 8 Oct 2010, Jason McIntyre wrote:
> ...
>>  On Fri, Oct 08, 2010 at 08:34:54PM +0200, Tilo Stritzky wrote:
>>  > >Description:
>>  >         When a command list contains && or ||, a set errexit option
>>  >         does not cause the shell to exit if the last command in the
>>  >         list returns non-zero.
>>  > >How-To-Repeat:
>>  >    /bin/sh -ec 'true && false ; echo $?, still alive'
>>  >    /bin/ksh -ec 'false || false ; echo $?, still alive'
>>
>>  the description of -e says as much:
>>
>>       -e | errexit
>>       Exit (after executing the ERR trap) as soon as an error occurs or
>>       a command fails (i.e.  exits with a non-zero status).  This does
>>       not apply to commands whose exit status is explicitly tested by a
>>       shell construct such as if, until, while, &&, ||, or !  statements.
>
> The issue isn't that the behavior and the documentation don't match.  The
> issue, perhaps not clearly stated, is that the behavior isn't what is
> required by POSIX/SUS.

POSIX says nearly the same as we do.

When this option is on, if a simple command fails for any of the
reasons listed in Consequences of Shell Errors or returns an exit
status value >0, and is not part of the compound list following a
while, until, or if keyword, and is not a part of an AND or OR list,
and is not a pipeline preceded by the ! reserved word, then the shell
shall immediately exit.

http://www.opengroup.org/onlinepubs/009695399/utilities/set.html

Reply via email to