View Single Post
Posts: 451 | Thanked: 334 times | Joined on Sep 2009
#7
Originally Posted by Joorin View Post
Environment variables are, by definition, bound to a certain process.

If you spawn a child process, it inherits the environment.

So, if you want your changes to stay available you need to run the process in the same environment as the one you changed.
I understand the logic, however I keep thinking there has to be a way to accomplish via a shell script the same effect in the current terminal that is achieved via sourcing a file, without having to source the top calling file.

Why I don't want to source the file is simple: I want the whole procedure to be callable via a command, that I can put in the path, so that the user doesn't have to worry about sourcing something.

But I want to be able to change the environment variables for the given shell environment and all the future spawned processes dynamically.

I keep thinking this has to be doable somehow...