linux 退出管道,linux – 在makefile中处理管道及其退出状态的最佳方式

你应该可以告诉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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值