[bash] Exported variable gone after end of script?
Hello
I'm using a simple Bash script to export an environment variable, eg. Code:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/my/own/dir Problem is, this change only occurs within the context of the script, and doesn't live beyond it. What is the right way to update an environment variable so that it "sticks"? Thank you. |
Hi
When you start a script, it runs in its own process. A process can't set the environment variables of the parent. But you can run a script without starting a new process. To do this, you have to prefix it with "source" or simply ".". source ./update.path.bash or . ./update.path.bash |
Thanks for the tip.
|
All times are GMT -5. The time now is 02:51 AM. |