Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
447 views
in Technique[技术] by (71.8m points)

@ prefix when setting environment variable in Makefile

Here is what I've got so far:

SPECS = $(shell find spec -iname "*_spec.js")

spec:
    @NODE_ENV=test 
    @NODE_PATH=lib 
    ./node_modules/.bin/expresso 
    $(TESTFLAGS) 
    $(SPECS)

cov:
    @TESTFLAGS=--cov $(MAKE) spec

.PHONY: spec cov

Output: /bin/sh: @NODE_PATH=lib: command not found

If I set one variable only it's working fine. What am I doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use '@' only once. It is only needed at the very beginning of the string, but you have it twice. The line continuations are very literal, and your current code reads:

@NODE_ENV=test @NODE_PATH=lib ./node_modules/.bin/expresso $(TESTFLAGS) $(SPECS)

The '@' on NODE_PATH is getting passed to the shell, which you do not want.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...