If a command is allowed to fail (suffixed with || or is within if condition), errexit in it is effectively disabled, and even setting it explicitly has no effect.
$ (set -e;
> set -o | grep errexit
> (set -o | grep errexit; set -e; set -o | grep errexit; false; echo "unexpected") || true;
> )
errexit on
errexit on
errexit on
unexpected
The best mitigation that I found is suffixing every command in a block that’s expected to run in this “mode” with || exit $? (|| return $? if in a function).
It is possible to edit the function to run the command in a way that doesn’t invoke this “mode”, using the fact that Travis’ logic runs without errexit:
Note though that since user commands are run in the current shell (by necessity as shell environment changes they make must persist for the following commands), exiting via -e will terminate the entire job immediately (not running stages like cache save), and you may not get full output unless you call travis_terminate upon exit.
I’ve merged the PR. This allows some reasonable workaround for the unexpected result. Since we are unable to overcome the errexit issue, I’ll advise you to concoct your own mechanism to deal with the error(s) inside your own sourced file.
If the change is up and running, then I guess that the strange behaviour should be fixed now: why do you suggest to concoct my own mechanism? My tests fail successfully (LOL).