Cool article but there are few things I need to disagree.
Using format foo=bar stores environment variable only current command. To keep environment variable loaded in your running bash process you need to export it with export foo=bar. This behaviour can be checked with commands env, printenv or by echoing environment variable.
Results of source and sh commands might look identical but they are not. Source command executes script in running bash and all exported envirenment variables are part of the running bash shell. sh invokes a new shell and exported variables are not usable in the calling shell. Also working directory of calling bash shell might be changed when using source command.
Please note that sh usually is linked to posh or some other lightweight shell which does not have all bash features.
In some systems source and . are interchangeable command. (POSIX compatibility is swamp)
Anyway source command is good if you need (temporary) setup your environment: e.g. load environment variables, aliases and even request passwords from user with read -s <variable_name> or to load functions from external libraries.
read -s <variable_name>
Usually source is used in scripts(1) but I'm sure that users can find use cases when to use source to setup environment for running shell.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.