gpt4 book ai didi

linux - Makefile 中的 $${HOME} 或 ${HOME}?

转载 作者:IT王子 更新时间:2023-10-29 01:25:28 29 4
gpt4 key购买 nike

$ cat Makefile 
all:
echo VAR is ${HOME}
echo VAR is $${HOME}

给予

$ make
echo VAR is /home/abc
VAR is /home/abc
echo VAR is ${HOME}
VAR is /home/abc

为什么 echo VAR is ${HOME} 语法在 Makefile 中有效?我想,要使用 shell 变量,您必须使用 $${HOME}}

最佳答案

是也不是。最好使用$$ 来明确。然而,there is a special rule for environment variables :

Variables in make can come from the environment in which make is run. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value. But an explicit assignment in the makefile, or with a command argument, overrides the environment. (If the `-e' flag is specified, then values from the environment override assignments in the makefile. See section Summary of Options. But this is not recommended practice.)

关于linux - Makefile 中的 $${HOME} 或 ${HOME}?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50751114/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com