Joined August 2018
·

Vampire

Germany
·
·
·

Which is explicitly mentione in the post

This particular option sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or zero if all commands of the pipeline exit successfully.

@kernrad how is that different or new?
He didn't show it with the return code but with "bar" not being printed.
But as far as I can see you just repeat what the entry said.
Did I miss something?

I'd like to suggest adding shopt -s inherit_errexit.
Without it, command substitution does not inherit the set -e.
Pipefail is inherited though in any case.
Without that shopt line, foo=$(gits --version; true); echo $foo will fail and print an error, but will not make the script fail.
With the option, the script is aborted on that error.
Strangely echo $(gits --version; true) will not make the script fail either way, but I guess this is a bug.

Achievements
1 Karma
0 Total ProTip Views