Preserve environments vars after shell script finishes
问题 How can I keep the environment variables, set from a shell script, after the script finishes running? 回答1: 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. 回答2: run the script as follows: source <script> -OR-