你应该可以告诉make使用bash而不是sh,并且bash将set -o pipefail设置为使得它在管道中首次出现故障时退出.
在GNU Make 3.81(大概早些虽然我不知道肯定),你应该能够用SHELL = / bin / bash -o pipefail这样做.
在GNU Make 3.82(和更新版本)中,您应该可以使用SHELL = / bin / bash和.SHELLFLAGS = -o pipefail -c(尽管我不知道如何添加-c到最后是必要的,如果make将为您添加,即使指定.SHELLFLAGS.
从bash手册页:
The return status of a pipeline is the exit status of the last command, unless the pipefail option is enabled. If pipefail is enabled, the pipeline’s return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully. If the reserved word ! precedes a pipeline, the exit status of that pipeline is the logical negation of the exit status as described above. The shell waits for all commands in the pipeline to terminate before returning a value.