As a simple workaround, you could run a shell in your current shell and source there. Something like:
Open a new terminal and set everything up the way you want it. You mentioned some environment variables and the like. Set them up here.
In that terminal, start a new shell. For instance,
bash.Do your thing. Source your script. If it exits, you're just thrown into the first shell and everything is still set up. Just run
bashagain and you're back in business.
To illustrate, I created this script which will fail if you try to source it:
$ cat /home/terdon/scripts/bar.sh set -o errexit var='bar'var='bar Let's see what happens if I start a nested shell session and then source it (note that I am using the portable name for the source command, .; source is a bashism):
parent-shell $ bash ## start a new shell child-shell $ . ~/scripts/bar.sh bash: /home/terdon/scripts/bar.sh: line 2: unexpected EOF while looking for matching `'' parent-shell $ As you can see, the syntax error caused the sourced script to exit which, in turn caused my shell session to exit but since it was a nested session, that just landed me back at the original, parent shell with all the variables still set up. Now, just run a new shell again and you can go back to sourcing your script.