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

查看:23
本文介绍了在 Makefile 中设置环境变量时的 @ 前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我到目前为止所得到的:

SPECS = $(shell find spec -iname "*_spec.js")规格:@NODE_ENV=测试@NODE_PATH=库./node_modules/.bin/expresso $(测试标志)$(规格)冠状病毒:@TESTFLAGS=--cov $(MAKE) 规范.PHONY:规格书

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

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

解决方案

只使用一次'@'.它只在字符串的开头需要,但你有两次.续行非常直接,您当前的代码如下:

<上一页>@NODE_ENV=test @NODE_PATH=lib ./node_modules/.bin/expresso $(TESTFLAGS) $(SPECS)

NODE_PATH 上的@"正在传递给您不想要的 shell.

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?

解决方案

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.

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

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