Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

When you run "./script.sh", you are telling the shell to execute the script as a separate process. The shell creates a new process to run the script, and any changes made to the environment (such as setting environment variables) by the script are only visible within that new process. The script is executed in a sub-shell and any changes made in the script to the environment variables, current working directory, etc. will not affect the parent shell that executed the script.

On the other hand, when you run "source script.sh", the script is executed within the current shell process, and any changes made to the environment by the script affect the current shell. The script is executed as if its commands were typed directly into the shell. This means that any changes made to environment variables, current working directory, etc. by the script will affect the parent shell that executed the "source" command.