When the script is done, any changes that it made to the environment are discarded. . script The above sources the script. It is as if the commands had been typed in directly. Any environment changes are kept. source script This also sources the script. The source command is not required by POSIX and therefore is less portable than the shorter ..
source is a shell keyword that is supposed to be used like this: source file where file contains valid shell commands. These shell commands will be executed in the current shell as if typed from the command line.
You have an alias which is overriding the builtin source (fix with unalias source) You have a function which is overriding source (fix with unset -f source) You are somehow not using bash (although your bang line would suggest you are). source is not POSIX. Using source on dash does not work, only . works.
2 source is there for readability and self-documentation, . exists because it is quick to type. The commands are identical. Perl has long and short versions of many of its control variables for the same reason.
I've read that BASH_SOURCE should be populated with the name of the executing script (and it works!). But why does BASH_SOURCE hold the name of the executing script, when it is defined in man bash as an array of source filenames corresponding to shell functions?
I accidentally sourced the wrong environment from a script. Is there any way to 'unsource' it or in other words to revert it and restore the previous environment? The obvious answer is to start fr...
What is the difference between sourcing ('.' or 'source') and executing a file in bash? Ask Question Asked 13 years, 4 months ago Modified 4 years, 9 months ago
34 source is a shell builtin, so it cannot be executed without the shell. However, by default, sudo do not run shell. From sudo Process model When sudo runs a command, it calls fork (2), sets up the execution environment as described above, and calls the execve system call in the child process If you want to explicitly execute shell, use -s option:
I.e., unpack the source package from your distribution, replace the source with the upstream version, check if any of the distribution's patches or configuration tweaks still apply, build the binary package (make sure you changed the version of the packaged stuff!) and install that one. Yes, it is more work than just building and installing.
However, when you source something, it is run in your current shell which, because it is interactive, has already loaded the aliases and therefore the fi alias is recognized and breaks the sourcing.