4 bash shell makefile gnu-make
有没有什么方法可以在错误发生时输出错误信息。详细说一下,我想知道一个文件内容是否等于另一个文件内容。如果不是,make应该退出并输出错误信息。
test:
cmp --silent tmp/test.txt tmp/test_de.txt || (error DecryptFile is different from original)
Run Code Online (Sandbox Code Playgroud)
当tmp/test.txt不等于时tmp/test_de.txt,输出为:
cmp --silent tmp/test.txt tmp/test_de.txt | (error DecryptFile is different from original)
/bin/sh: 1: error: not found
makefile:38: recipe for target 'test' failed
make: *** [test] Error 127
Run Code Online (Sandbox Code Playgroud)
/bin/sh: 1: 错误:未找到
结果不是我想要的。我只是想要这样的错误信息:
makefile:38: *** missing separator. Stop.
Run Code Online (Sandbox Code Playgroud)
tor*_*mas 10
您可以使用exit. 的(和)能够包围一个以上的命令:
cmp --silent tmp/test.txt tmp/test_de.txt || (echo "DecryptFile is different from original"; exit 1)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9899 次 |
| 最近记录: |