Difference between filename and . filename in macOS terminal
I'm newbie to MacOS. (I'm using mac OS high sierra 10.13.6) I installed a software. They said to initialize the software by
. /path/setsas.sh
I give no thought to . and space, so I just ran
path/setsas.sh
It seemed to run, but after that I couldn't execute any command of the software. I found that I should have ran the command as it were, and after that it was fine. So what these . and space mean here, and any guess why I couldn't execute any command at first even though file seemed to run? I know that . sometimes mean current folder, but it doesn't look like it in this case.
Solution 1:
. /path/setsas.sh
loads the variables and functions from the script into your current shell session. It's the same as running source /path/setsas.sh
. Running path/setsas.sh
on the other hand spawns a new process. The variables and functions will not be accessible from your current shell. That's why the commands weren't working for you.