set -e; (false && true); echo hi
does nothing, but set -e; false && true ; echo hi
prints hi. set -e; (false && true); echo hi
does nothing, but set -e; false && true ; echo hi
prints hi. function foo { false; true; }
foo || echo foo failed
prints nothing.https://news.ycombinator.com/item?id=24740842
shopt -s strict_errexit in Oil disallows that (a runtime assertion 100% of the time). Feedback is welcome! https://github.com/oilshell/oil/issues/709
My guess was that the () affects the order of operations between ; and &&, so the first line is three commands, while the second line is two.
"Placing a list of commands between parentheses causes a subshell environment to be created"
"Placing a list of commands between curly braces causes the list to be executed in the current shell context"
>My guess was that the () affects the order of operations between ; and &&, so the first line is three commands, while the second line is two.
Emphasis mine. My understanding was that the question is simply about whether () invokes a subshell or not (irrespective of set -e)
https://news.ycombinator.com/item?id=24740842
The problem actually has more to do with the definition of $? than the set -e behavior itself. And the fact that POSIX specifies that the error a the LHS of && is ignored (a fundamental confusion between true/false and success/error)
The exit code of the function is not what you expect, or the exit code of the subshell is not what you expect.
I made a note of it on the bug ... still thinking about what the solution to that one is.
(The other solutions are inherit_errexit, more_errexit, and a "catch" builtin.)