为什么我的 Makefile 不在命令中插入表达式 [英] Why doesn't my Makefile interpolate an expression in a command
本文介绍了为什么我的 Makefile 不在命令中插入表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个超级简单的 Makefile
来在 Go 项目中运行测试.该项目的依赖项是供应商的,但我想跳过这些测试.从命令行运行时,我只是做
I'm trying to write a super simple Makefile
to run the tests in a Go project. The project's dependencies are vendored, but I want to skip these tests. When running this from the command line I simply do
$ go test $(go list ./... | grep -v /vendor/)
然而,当我像这样把它放入 Makefile
时:
Yet, when I put this into a Makefile
like this:
test:
go test $(go list ./... | grep -v /vendor/)
.PHONY: test
表达式不会被计算:
$ make
go test
? github.com/m90/some-repo [no test files]
如何让 make 以类似 shell 的方式插入表达式?
How do I get make to interpolate the expression in a shell-like manner?
推荐答案
在 Makefile 配方部分,您需要使用第二个 $
对 $
进行转义:>
In a Makefile recipe section you will need to escape the $
using a second $
:
test:
go test $$(go list ./... | grep -v /vendor/)
.PHONY: test
这篇关于为什么我的 Makefile 不在命令中插入表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文