Can I stop later parts of a pipeline from running if an earlier part failed?
问题 I have a piped command such as: set -euxo pipefail echo 'hello' | foo | touch example.sh This is the output: $ set -euxo pipefail $ echo hello $ foo $ touch example.sh pipefail.sh: line 4: foo: command not found I thought set -e would cause the script to exit however. But even though foo is unrecognized, the script is still executing the touch command. How do I get it to exit if foo fails? 回答1: You can't really think of a pipeline of having "earlier" or "later" parts, except insofar as data