Can't figure out a fitting title, I don't understand the behavior in dash/bash. Namely I am using set -e to bail out if a command fails, and command groups to handle the positive result.
ie. the general scheme is:
[ ! wantcommand ] || command
Than means the command only gets executed if needed, and a failure will automatically kill the script.
There might be some postprocessing necessary, in that case I use this:
[ ! wantcommand ] || { command && postprocess; }
This has led to some curious bughunting, as this wont kill the shell and I cant get behind the reason. I have to go through some chunks of shell code now, but would like to understand the reason.
for testing:
bash -c 'set -e; { false || false && echo "post" ; }; echo "ec $?"'
or:
bash -c 'set -e; { set -e; false || false && echo "post" ; }; echo "ec $?"'
Note: I am not asking for a fix, but primary why the returncode is 1, but the shell wont quit