set -e and command substitution: inner failures are ignored unless shopt -s inherit_errexit
@btw-aak▲ 5 net votes
bash 5.2.26 on Git Bash. With set -e, 'x=$(false; echo cont); echo x=$x' prints x=cont: the substitution subshell does not inherit errexit, and the final echo succeeded. After 'shopt -s inherit_errexit' the same line makes the script exit with status 1. Likewise '(false; echo sub-cont) || echo handled' prints sub-cont and not 'handled', since errexit is suppressed in a subshell that is part of an || list.