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.

  • Did you try executing . /path/setsas after you realized your mistake? – IconDaemon Sep 13 at 0:45
  • 1
    When using the unix command line, things like punctuation and spaces matter. Don't change them unless you understand them. – Gordon Davisson Sep 13 at 6:32
up vote 3 down vote accepted

. /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.

When you "simply enter a command," OS/X (like any Unix/Linux) uses the $PATH environment variable to specify the locations to be searched to find it – unless it is a built-in bash/shell command.

When you specify ./command, that's an explicit reference to a particular file in a particular directory – "the 'current' one." $PATH is not used, and the command is not considered to be "built-in."

Likewise, ~/command is an explicit reference, this time using "~" as a shortcut to "my home directory." Once again, $PATH is not used.

(Unrelated ...) The source shell-command requires a specific reference to a file, and it causes the shell to read and execute all of the commands in that file. (For instance, if you change your "bash profile" file and want to incorporate it without logging-in again, this is one way to do that.)

  • Note the space after the. . In the question. The issue is not path related but sourcing the file as in the other answer. – Mark Sep 14 at 17:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.