I'm writing a script as part of a process to restore a broken environment. It sources a couple of other scripts, and I want all of those variables to be maintained on the command line after running the script. For this reason, the script needs to be run using . script.sh and not using bash script.sh.
I want to add a line or two in the script to make sure that the user has invoked the script correctly, and not used bash script.sh, as this will cause problems further along in the process.
How can I test whether or not the script was invoked using . script.sh (or at least that the sourced commands will persist after the script has completed)?
. ./script.shorsource ./script.shas opposed to./script.shorbash ./script.sh.