Reputation: 3099
I use a shell (bash, but I need portability) and a GNU Makefile. I have this code:
check_commands:
command -v find >/dev/null
command -v asdf >/dev/null
As supposed, the first command is passed, the second aborts the Makefile with an error. Now, I remove the >/dev/null
. Why does then
check_commands:
command -v find
produce the following error?
make: command: Command not found.
Upvotes: 4
Views: 777
Reputation: 10148
Judging from a quick look at job.c
in GNU make's sources, it attempts to avoid launching a shell when it can, i.e. when the command line is simple enough (of the form cmd args
, without redirection, compound commands, etc.) and the shell is the default one. The issue is then that command
is a built-in and does not have an associated executable, hence the error message from make. It does not occur when you have > /dev/null
as make considers the command as too complicated and leaves it to sh
to launch it.
Upvotes: 15