【发布时间】:2020-05-11 21:35:55
【问题描述】:
在我的 Makefile 中,我使用 grep 将未找到某些模式的文件的内容输出到另一个文件中。但是,这仅在 grep 命令有一些输出时才有效,否则无效。我宁愿在运行它时不要使用任何开关。这就是我的 Makefile 中的内容
all:
@(grep -v -e -define file1 | grep -v -e -libfile | grep -v -e pattern3 >> file2)
如果 file1 中有不包含 -define 或 -libfile 的行,但 file1 中的所有行都具有这种模式,因此 grep 不返回任何内容然后 make 失败并出现此错误:
Makefile.test:3: recipe for target 'all' failed
make: *** [all] Error 1
该命令在 shell 中运行良好,因此这与 grep 返回 -1 并杀死 make 有关 - 有没有更好的方法来做到这一点?
【问题讨论】:
标签: shell makefile command return-value