The logic here is that your use of &&
already is error-checking. The same way bash doesn't treat a failure within an if
condition as worth aborting, even with set -e
.
When you wrap the commands in a parenthesis, you are actually running those commands within a subshell, so the script itself only sees the return of that subshell, ie: it isn't aware that &&
is involved at all, so it aborts as you expect.