Going through a MakeFile I find
PROJECT_ROOT = $(shell pwd)
What value does it give?
$SHELL
gives the shell and $PWD
gives present working directory
But what does $(shell pwd) give?
$(...) allows command substitution, i.e. allows the output of a command to replace the command itself and can be nested. Follow this answer to receive notifications. edited Dec 23, 2018 at 19:57.
The pwd command writes to standard output the full path name of your current directory (from the root directory). All directories are separated by a / (slash). The root directory is represented by the first /, and the last directory named is your current directory.
The dollar sign before the thing in parenthesis usually refers to a variable. This means that this command is either passing an argument to that variable from a bash script or is getting the value of that variable for something.
To determine the exact location of your current directory within the file system, go to a shell prompt and type the command pwd. This tells you that you are in the user sam's directory, which is in the /home directory. The command pwd stands for print working directory.
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 pwd
at the bash shell prompt.
So, $(shell pwd)
will return the current working directory. You may not be guaranteed that the $PWD
variable exists in your make environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With