[英]Nested command substitutions in a makefile
I have a pretty basic makefile where I want to use the name of the current project / folder, but I keep having problems. 我有一个非常基本的makefile,我想在其中使用当前项目/文件夹的名称,但是我仍然遇到问题。 I've tried:
我试过了:
example:
docker build -t `basename `pwd`` .
docker build -t `basename $(pwd)` # From what I know $() relates to a variable in makefiles.
Any ideas? 有任何想法吗?
One approach: 一种方法:
docker build -t `basename $(PWD)`
This, like many environment variables, is all uppercase. 就像许多环境变量一样,它们都是大写的。
As was pointed out in the comments, this: 正如评论中指出的那样:
docker build -t $$(basename $$(pwd))
will also work. 也可以。 This is more akin to your first attempt, where the
pwd
command is used rather than the PWD
environment variable. 这更类似于您的第一次尝试,其中使用了
pwd
命令而不是PWD
环境变量。
And, this will also work: 并且,这也将起作用:
docker build -t `basename \`pwd\``
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.