Source files in a bash script

Solution 1:

Execute Shell Script Using . ./ (dot space dot slash)

While executing the shell script using “dot space dot slash”, as shown below, it will execute the script in the current shell without forking a sub shell.

$ . ./setup.bash

In other words, this executes the commands specified in the setup.bash in the current shell, and prepares the environment for you.

Solution 2:

Use dot notation to source in the script file in the current shell i.e. without creating a sub-shell:

. /opt/ros/fuerte/setup.bash
. ~/fuerte_workspace/setup.bash