gpt4 book ai didi

bash - Makefile 错误退出并显示一条消息

转载 作者:行者123 更新时间:2023-11-29 09:37:34 25 4
gpt4 key购买 nike

有没有办法在错误发生时输出错误消息。让我们详细说明,我想知道一个文件内容是否与另一个文件内容相等。如果不相等,make 应该退出并输出错误信息。

test:
cmp --silent tmp/test.txt tmp/test_de.txt || (error DecryptFile is different from original)

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

/bin/sh: 1: error: not found

结果不是我想要的,我只是想要这样的错误信息:

makefile:38: *** missing separator. Stop.

最佳答案

您可以使用exit() 可以包含多个命令:

cmp --silent tmp/test.txt tmp/test_de.txt || (echo "DecryptFile is different from original"; exit 1)

关于bash - Makefile 错误退出并显示一条消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44061611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com