This is by design.
User commands run without errexit – because, by necessity, they are run with eval in the same shell as other build logic (so that environment changes they make are seen by further commands), so errexit would break the enveloping internal logic.
You have a few options here:
-
Put the commands into a separate script and run it (with
-eor whatever), as a subprocess. -
Invoke consecutive commands as
cmd1 && \ cmd2 && \ etcso that the status of the first failed command propagates to exit status of the entire
ifcompound command. -
Run the block in a subshell with
-e:- | (set -e <etc> )