To Source Or Not To Source

Going through some old Bash files, I noticed this kind of thing
source filename.shHere’s a good answer on Stack Overflow explaining why the source command is used:
Running the command
sourceon a script executes the script within the context of the current process. This means that environment variables set by the script remain available after it’s finished running. This is in contrast to running a script normally, in which case environment variables set within the newly-spawned process will be lost once the script exits. You cansourceany runnable shell script. The end effect will be the same as if you had typed the commands in the script into your terminal.
For example, if the script changes directories, when it finishes running, your current working directory will have changed.
To see this, create a file
test.shwith contents
#!/bin/sh
cd moviesand a directory movies.
mkdir moviesChange the file’s permissions
chmod u+x test.shRun the file normally
./test.sh
pwdwhich shows the same directory.
Now try running the file with source
source test.sh
pwdwhich shows you are in movies.