Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: environment settings



On Tue, Jun 17, 2008 at 08:33:02AM +0000, J?rg Sommer wrote:
> And what's the meaning of .zshenv? I use it for my environment variables
> like EDITOR, because my session is started by X.

I've been bitten by unwanted side effects when using .zshenv to set
environment variables, so the following lines are pretty much the
entirety of my .zshenv file these days:

if [[ $SHLVL == 1 && ! -o LOGIN ]]; then
    source ~/.zprofile
fi

The problem I ran into with setting variables in .zshenv is that they
can override settings you want to affect a program and/or script when
you don't expect it.  For instance, if you need to debug a C program
that is run inside a script with a custom PATH.  You setup the custom
PATH and run the C program under gdb, and discover that your PATH isn't
set right for the C program.  This is because gdb starts the program
under an instance of $SHELL, which will source .zshenv, and if you're
setting PATH inside, that blasts the PATH setting you're expecting.
A similar problem arises for any zsh script that you want to run inside
a customized environment -- the .zshenv values always override any
settings you made prior to starting the script.

..wayne..



Messages sorted by: Reverse Date, Date, Thread, Author