I saw a question recently where a user wanted to ensure that his script is only executed by using source
.
My question is: what's the difference between ./test_script.sh
and source test_script.sh
? I do know that when source
is used the script file doesn't need +x permissions. Are there any other differences? And my second question is: in what kinds of situations is each method appropriate?
man source
– Matt Feb 16 '18 at 03:01source
. Andhelp source
is just 5 sentences long and basically just says the FILENAME is executed in the current shell and what the exit status can be. I'd like a more in depth explanation. – nagamani Feb 16 '18 at 03:07