Joh*_*nes 2 shell makefile gnu-make
我使用shell(bash,但我需要可移植性)和GNU Makefile.我有这个代码:
check_commands:
command -v find >/dev/null
command -v asdf >/dev/null
Run Code Online (Sandbox Code Playgroud)
假设,第一个命令被传递,第二个命令中止Makefile并出错.现在,我删除了>/dev/null.那为什么呢
check_commands:
command -v find
Run Code Online (Sandbox Code Playgroud)
产生以下错误?
make: command: Command not found.
Run Code Online (Sandbox Code Playgroud)
Vir*_*ile 12
从job.c在GNU make的源代码中快速浏览来看,它试图避免在可能的情况下启动shell,即当命令行足够简单时(形式cmd args,没有重定向,复合命令等)并且shell是默认的一.那么问题是command内置的并且没有关联的可执行文件,因此来自make的错误消息.当你> /dev/null认为命令过于复杂并将其留给sh启动它时,就不会发生这种情况.