我有一个make文件中的以下代码,我知道如果不存在,它将在Home中创建bin文件夹...但是我不明白$ HOME / bin是什么意思...
我在Google上搜索后发现$$是要获取bash的进程ID ...但是无法理解$$ HOME / bin是什么意思...有人可以解释一下吗?
.PHONY: home_bin
home_bin: ## Create home bin if not created
@ if [[ ! -d "$$HOME/bin" ]]; then \
echo "Creating $$HOME/bin"; \
mkdir $$HOME/bin; \
echo "✔︎ $$HOME/bin created"; \
else \
echo "✔︎ $$HOME/bin already created"; \
fi
谢谢。
make
itself performs expansion of$
-prefixed characters; the$$
is expanded to a single literal$
to pass to the shell.考虑一个简单的Makefile:
which will output
foo
, becausemake
expands$x
to the single characterf
.make
passes the stringxoo=3 && echo foo
to the shell for execution与之比较
which outputs
3
, becausemake
expands$$
to$
make
passes the stringxoo=3 && echo $xoo
to the shell for execution