a question - in some case, I saw command line like this
. ./test.sh
I'm curious why use "." before "./test.sh" what condition we have to use "." before a command?
a question - in some case, I saw command line like this
I'm curious why use "." before "./test.sh" what condition we have to use "." before a command?
Running . ./test.sh
is similar to running source ./test.sh
. It's not running the file test.sh
as an executable. Instead it's running it's contents line by line into your current shell. So it could for example also modify your current environment.
Running . ./test.sh
is the same as source ./test.sh
. It runs the script in the current shell rather than a subshell (i.e. it does not fork). This may change variables of same name in the calling script, and it will leave variables and functions which were defined in ./test.sh
also defined and visible after the call in the calling script.