为什么我的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
表达式将不会被评估:
the expression will not be evaluated:
$ 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配方节中,您需要使用escape < c> $ 使用第二个 $
:
In a Makefile recipe section you will need to use escape the $
using a second $
:
test:
go test $$(go list ./... | grep -v /vendor/)
.PHONY: test
这篇关于为什么我的Makefile没有在命令中插入一个表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文