>"The -e setting shall be ignored when executing the compound list following >the while, until, if, or elif reserved word, a pipeline beginning with the >! reserved word, or any command of an AND-OR list other than the last." > >(from >https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_25_03) > >The subshell inherits this state (being part of an and-or list) from its >parent.
Is that really the intent of the requirement, though? The same section states: "This requirement applies to the shell environment and each subshell environment separately", which I read to mean that the rules should be evaluated without consideration of any parent or subshell environment other than the one in which the -e option is being applied. And the example: set -e; (false; echo one) | cat; echo two shows rule 1 ("The failure of any individual command in a multi-command pipeline shall not cause the shell to exit") not being applied within the subshell, even though the subshell as a whole is an "individual command in a multi-command pipeline". I don't see any suggestion that the case of an AND-OR list in rule 2 should be treated differently, and absent an explicit requirement one way or the other, I think the expected behavior here would be that the behavior of the subshell is independent of the subshell's context in the parent shell. --Andrew Church http://achurch.org/