On 5 Feb 2003 06:16:32 -0800, Alexandre Ferrieux
Quote:> This thread was initially about whether it is a bug or a feature, that
> bash pedanticly sticks to the POSIX-sufficient requirement that 'set -e'
> exit only after getting a nonzero status from a "simple command", while
> the original Bourne makes a very useful generalization to "any child"
> (including subshells).
I think POSIX specification is another way to formulate Bourne
shell behavior. A non-simple command is always composed of
simple commands (when it's not ("case a in; esac"), the exit
code is 0). So, whenever a non-simple command has a non-zero
exit-status, that means that a simple-command failed, so, the
shell should exit (there's no reference to subshells).
Note that POSIX is not consistant on (at least) one point:
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.
That would mean that a pipeline (such as "( foo ) | while ...")
is a simple command! Even though they meant "and is not part of
a pipeline...", that would mean that "false | true" should exit
the shell, as false is a simple command!
Another point not clear:
For me (as for bash, ksh or zsh), "true && false" should exit
the shell. But "false" is "part of an AND list"!
To sum up, my understanding is that bash is not POSIX compliant,
that the POSIX specification is not clear and that bsh/ksh/zsh
behavior is the right one.
So I think we mostly agree.