I came across some odd behavior when using Make recently (v3.81).
Suppose I have the following Makefile:
FOOBAR = $(shell find nonexistentdirectory -iname "foobar" | tr '\n' ' ')
all:
@echo "Hi"
clean:
@echo "Hi again"
Seems straightforward enough, right? Notably, FOOBAR is a "recursively-expanded variable", so it should not be evaluated until I refer to it. Note that I never refer to it. Also note that nonexistentdirectory does not exist as you might expect.
Now suppose I set FOOBAR in the shell before I invoke a Make target:
compy386$ FOOBAR="stuff" make clean
find: nonexistentdirectory: No such file or directory
Hi again
Why is FOOBAR being evaluated? Clearly it has something to do with the fact that the variable is defined in the shell. Am I supposed to anticipate that a user might have set variables in their shell? What am I doing wrong here?!