bash $(shell pwd) 给出什么值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15050748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 04:38:53  来源:igfitidea点击:

What value does $(shell pwd) give?

linuxbashmakefile

提问by Shorn Jacob

Going through a MakeFile I find

通过我发现的 MakeFile

PROJECT_ROOT = $(shell pwd)

PROJECT_ROOT = $(shell pwd)

What value does it give?

它赋予什么价值?

$SHELLgives the shell and $PWDgives present working directory But what does $(shell pwd) give?

$SHELL给出 shell 并$PWD给出当前的工作目录 但是 $(shell pwd) 给出了什么?

回答by Austin Phillips

The $(shell)function calls out to the shell to execute a command. The command being executed in this case is pwd, like if you ran pwdat the bash shell prompt.

$(shell)函数调用外壳程序以执行命令。在这种情况下执行的命令是pwd,就像您pwd在 bash shell 提示符下运行一样。

So, $(shell pwd)will return the current working directory. You may not be guaranteed that the $PWDvariable exists in your make environment.

因此,$(shell pwd)将返回当前工作目录。您可能无法保证该$PWD变量存在于您的 make 环境中。