. script . script and source script execute the contents of the script in the current environment, i.e. without creating a subshell. At the top, this allows the script affect the current environment, for example, change environment variables or change the current working directory. On the other hand, this allows the script affect the current environment, which is a potential security risk.
bash script passes the script the bash interpreter for execution. No matter what shebang is given by the script itself, it is ignored. ("Shebang"), referring to the first line of the script , which can, for example, read #!/bin/bash or #!/usr/bin/perl or #!/usr/bin/awk to indicate the interpreter to be used .)
$SHELL script passes the script all you need to execute the current shell interpreter. It may or may not be bash . (The SHELL environment variable contains the name of your current shell interpreter. $SHELL , if bash is executed, evaluates to /bin/bash , with the effect described in detail in the previous paragraph.)
./script executes the contents of the script file in the current working directory. If there is no such file, an error is generated. The contents of $PATH do not affect what happens.
script looks for the script file in directories listed in $PATH , which may or may not include the current working directory. The first script found in this directory listing is executed, which may or may not be specified in your current working directory.
source share