在Makefile中设置环境变量时的@前缀 [英] @ prefix when setting environment variable in Makefile

查看:150
本文介绍了在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

输出:/bin/sh: @NODE_PATH=lib: command not found

如果我只设置一个变量,它就可以正常工作.我在做什么错了?

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

推荐答案

仅使用'@'一次.仅在字符串的开头需要它,但是您有两次.这些行的延续非常直观,您当前的代码为:

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)

NODE_PATH上的'@'传递给了您不需要的shell.

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

这篇关于在Makefile中设置环境变量时的@前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆