I want my shell scripts to fail whenever a command executed with them fails.
Typically I do that with:
set -e set -o pipefail
(typically I add
set -u also)
The thing is that none of the above works with process substitution. This code prints "ok" and exit with return code = 0, while I would like it to fail:
#!/bin/bash -e set -o pipefail cat <(false) <(echo ok)
Is there anything equivalent to "pipefail" but for process substitution? Any other way to passing to a command the output of commands as it they were files, but raising an error whenever any of those programs fails?
A poor's man solution would be detecting if those commands write to stderr (but some commands write to stderr in sucessful scenarios).
Another more posix compliant solution would be using named pipes, but I need to lauch those commands-that-use-process-substitution as oneliners built on the fly from compiled code, and creating named pipes would complicate things (extra commands, trapping error for deleting them, etc.)