How can I keep the environment variables, set from a shell script, after the script finishes running?
This is not possible by running the script. The script spawns it's own sub-shell which is lost when the script completes.
In order to preserve export
s that you may have in your script, you can call them like this, which will add them to the current environment:
. myScript.sh
Notice the space between the .
and the myScript.sh
section.