How to capture all the environment variables from shell?

Nobody nobody at nowhere.com
Tue Jul 27 06:21:29 EDT 2010


On Mon, 26 Jul 2010 21:42:24 -0500, Tim Chase wrote:

>> Please! Never export anything from your .bashrc unless you
>> really know what you're doing. Almost all exports should be
>> done in your .bash_profile
> 
> Could you elaborate on your reasoning why (or why-not)?  I've 
> found that my .bash_profile doesn't get evaluated when I crank up 
> another terminal window, while my bashrc does.  Thus I tend to 
> put my exports in my ~/.bashrc so they actually take effect in my 
> shell...

Ideally, whichever program spawns the terminal window should have all of
the environment settings from your ~/.profile (although you may have
to explicitly source it from e.g. ~/.xsession), so it shouldn't be
necessary to export them again.

Using ~/.bashrc is a band-aid in case your desktop session doesn't already
have your environment settings. But it only works for shells (and only for
bash shells, and only for interactive bash shells), while your environment
settings should be available to everything, regardless of whether it was
spawned from an interactive bash shell or from some other program.

Also, if you update environment variables with e.g.:

	export PATH=$PATH:/usr/local/bin

any nested shells end up getting multiple updates.




More information about the Python-list mailing list