Make fails to export the 'SHELL' variable.
The docs reads:
Furthermore, when you do set 'SHELL' in your makefile that value is not exported in the environment to recipe lines that 'make' invokes. Instead, the value inherited from the user's environment, if any, is exported. You can override this behavior by explicitly exporting 'SHELL' (*note Communicating Variables to a Sub-'make': Variables/Recursion.), forcing it to be passed in the environment to recipe lines.
And further elsewhere, we have:
The value of the 'make' variable 'SHELL' is not exported. Instead, the value of the 'SHELL' variable from the invoking environment is passed to the sub-'make'. You can force 'make' to export its value for 'SHELL' by using the 'export' directive, described below.
ifeq "$(MAKELEVEL)" "0"
export SHELL
all:
@$(MAKE)
else
all:
@-foo;
endif
.PHONY: all
running as:
$ make SHELL=bash -e
We get:
make[1]: Entering directory '/home/myname'
/bin/sh: 1: foo: not found
makefile:13: recipe for target 'all' failed
make[1]: [all] Error 127 (ignored)
make[1]: Leaving directory '/home/myname'
If you take a close look at the 2nd line above, you'll see that the default (/bin/sh
) shell executed the commands.
Now, that's despite of an explicit export
on the SHELL variable, as advised by the docs, cited above. Why?
Make version is the latest!