On Tue, Nov 17, 2020 at 4:07 PM Pierre Colombier via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org> wrote:
> #2 > pierre@zebulon: ~ $ (set -e ; echo A ; false ; echo B ) && echo C.$? > #3 > pierre@zebulon: ~ $ bash -c 'set -e ; echo A ; false ; echo B ' && echo > C.$? If it's not a bug, I think the manual should explain the difference > between #2 and #3 in section 3.2.3 and 3.2.4.3 > Technically, I suppose the description of set -e already says that (4.3.1 The Set Builtin): "If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the -e setting, even if -e is set and a command returns a failure status. " The subshell (set -e; echo...) is a compound command, and it executes as a non-final part of the && list, so none of the commands within are affected by set -e. The other command explicitly invoking bash is not a subshell or any other type of compound command. Now, perhaps that could use a note explicitly saying this also means subshells, even though they may have set -e in effect independently of the main shell. The part explaining subshells (3.7.3 Command Execution Environment) could perhaps also use a mention of that caveat, since it does mention set -e already, though in the context of command substitution. https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html