Did you ever realize that even when you use `set -e` in a bash script, anything that happens inside a $(subshell like that) won't be executed under the `set -e` umbrella?
Here are the 2 solutions we found. None feels very solid... but hey, it's bash, what did you expect?
- https://lists.gnu.org/archive/html/bug-bash/2008-01/msg00121.html . Apparently traps work in this dynamic scope and they get access to the nesting level of the bash shell the code is called from. Kind of not unwinding the stack?
- https://unix.stackexchange.com/questions/65532/why-does-set-e-not-work-inside-subshells-with-parenthesis-followed-by-an-or . running the subshell as a background task and immediately waiting for it, like a 1process forkjoin. Nuts.