3 ms·
If I have something I know can fail, and I want it to be able to, then calling set +e before it, and recalling set -e afterwards is the way I handle it. But, i
by shakna 7y ago
If I have something I know can fail, and I want it to be able to, then calling set +e before it, and recalling set -e afterwards is the way I handle it.
But, in this case, because you're running it in a subcommand, you need to add pipefail.
set -euo pipefail
This way of making sure nothing misbehaves also locks out unset vars, which can be surprising, but also helpful.
- arendtio 7y agoAs far as I can tell, adding pipefail or nounset doesn't change the behavior in this case. In my opinion, the problem is that calling a function from a test expression, evaluates it in a different manner than calling it from elsewhere. That is so absurd that I wonder how it wasn't changed over the years.