1) The built-in command
source executes the other script in the current shell environment. So that would override whatever you have in the shebang in the other script. Maybe that makes a difference, maybe not.
For example, if the first script runs with #!/bin/bash and the second script with #!/bin/sh, calling the second script with
source will make it run under
bash instead of
sh.
2) Unless you called the second script with
exec, it will return to the first script where it was called. However, the exit code it carries with it will depend on what you have at the end, see next.
3) A script will return the exit code from whatever command was its final one, unless it was overridden. So using
exit command overrides the last command in the script and returns a final code for the script as a whole.
Code:
#!/bin/sh
/bin/false
versus
Code:
#!/bin/sh
/bin/false
exit 0
The first script above will return 1 and the second script will return 0. So
exit is useful if you want to track whether the script as a whole succeeded or failed.