[wplug] Managing Environment Variables - Follow-up

Jonathan Billings billings at negate.org
Tue Dec 1 12:01:14 EST 2009


On Tue, Dec 01, 2009 at 11:23:05AM -0500, Weber, Lawrence A wrote:
> That's how I understand it.  So when I started a terminal, that subshell
> and all of the subshells it creates should have used the value that I
> sourced in my script.  The script set values of environment variables
> that were no longer in .bashrc or any other file.  Somehow (I hate to
> use that word) the makefiles that my main makefile was calling were able
> to access very old values of the environment variables.  This feature
> went away after a reboot.  So I have two questions that will never be
> answered, why did the called makefiles not use the current values, and
> where did they find the old values?  Thanks for your help.  I am going
> to have to let it drop as it is working now and I have lots to do.

You asked a question, but don't want to know an answer.  For the
benefit of the community, though, I think I'll take a stab at
answering and you can simply delete this email.

I think you're still misunderstanding how environment variables work.
It sounds like you removed the variable definitions from your
.bashrc, and then sourced a file with new definitions of the same
variables.

Unless you changed your .bashrc to set the variables to something
else, they will continue to be set in new shells to whatever value
they were set in your .bashrc when you first logged in.  Sourcing a
file where they're set again will temporarily change the values in the
executing shell, but once you terminate that shell any new shells you
start will continue to have their environment from their parent shell
with the old values.

If you're still reading, I do suggest you look into Environment
Modules, it was written to solve the problem you're encountering now.
We use then quite often to set up build environments for researchers
who want to have access to different libraries, compilers and
executables, installed next to each other, and still be able to use
the same makefiles.

-- 
Jonathan Billings <billings at negate.org>


More information about the wplug mailing list