Calling `command -v find` from the GNU Makefile

I use the shell (bash, but I need portability) and the GNU Makefile. I have this code:

check_commands: command -v find >/dev/null command -v asdf >/dev/null 

As expected, the first command is passed, the second aborts the Makefile with an error. Now I delete >/dev/null . Why, then

 check_commands: command -v find 

output the following error:

 make: command: Command not found. 
+2
shell makefile gnu-make
Oct. 20 '12 at 15:25
source share
1 answer

Judging by a quick look at job.c in GNU make sources, it tries to avoid running the shell when possible, that is, when the command line is simple enough (forms cmd args , without redirection, compound commands, etc.), and the shell - default. The problem is that command is built-in and does not have an executable file associated with it, hence the error message from make. This does not happen if you have > /dev/null , since make considers the command too complex and leaves sh to run it.

+9
Oct 20 '12 at 19:12
source share



All Articles