[lug] How does bash "set -e" work?
nagler at bivio.biz
Sat Dec 29 09:50:31 MST 2012
I've always wondered about "set -e" in subshells. Here's a simple script:
sh -x <<'EOF'
(set -e; false; echo not1) || echo ok1
(set -e; false; echo not2); echo ok2
(false && echo not3) || echo ok3
(false && echo not4); echo ok4
What I would expect is:
However, that's not the case. I get:
It seems that the "set -e" is affecting the parent shell.
Am I missing something?
More information about the LUG