Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What value does $(shell pwd) give?

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?

like image 869
Shorn Jacob Avatar asked Feb 24 '13 10:02

Shorn Jacob


People also ask

What does $() mean in shell?

$(...) 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.

What is the output of pwd command?

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.

What does $() mean in Bash?

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.

How can I get pwd in shell?

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.


1 Answers

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.

like image 121
Austin Phillips Avatar answered Sep 21 '22 18:09

Austin Phillips