在Makefile规则中redirectstdout和stderr

我想将脚本的输出redirect到不同的程序。 我通常会使用这两种forms:

python test.py 2>&1 | pyrg python test.py |& pyrg 

我的问题是,它不能从一个生成文件中工作:

 [Makefile] test: python test.py 2>&1 | pyrg [doesn't work] 

我希望避免写一个脚本文件来完成这个工作。

编辑:

这似乎是一个pyrg问题:

 python test.py 2>&1 | tee test.out // Writes to the file both stderr and stdout cat test.out | pyrg // Works fine! python test.py 2>&1 | pyrg // pyrg behaves as if it got no input 

这对我来说是一个糟糕的解决scheme,因为在testing失败的情况下,我从来没有去过cat部分(一切都在Makefile规则中)

我偶然发现了同样的问题,不满意答案。 我有一个在测试用例example2.TLBN上失败的二进制TLBN

这是我的make文件首先看的。

 make: ./TLBN example2.TLBN > ex2_output.txt 

其中失败的错误消息,我期待和停止制作过程。

这是我的修复:

 make: -./TLBN example2.TLBN > ex2_output.txt 2>&1 

请注意-在告诉make忽略任何输出到stderr的行的开头。

希望这可以帮助有类似问题的人。

这并不能解释为什么简单的方法不起作用,但它的确有诀窍:

 [Makefile] test: python test.py >test.out 2>&1; pyrg <test.out