There is already a question "What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?".
I'm wondering why anyone ever puts anything in
~/.zshenv. For those who are unfamiliar, these files are generally sourced on every
zsh invocation, even when it is executing a script file. Sourcing of the global file cannot be overridden; sourcing the local file can be prevented by executing
It just seems like a bad idea to have configuration files which change the behavior of all my Zsh scripts. Doesn't even the existence of this feature make Zsh scripts highly non-portable? I remember experiencing problems where system administrators put things in
/etc/zshenv which break my scripts or severely slow them.
And let's suppose that I only use
~/.zshenv to export environment variables - why should it be that I can temporarily override one of these variables when executing a Bash script, or a Perl script, but not a Zsh script? And why not simply configure these variables in
~/.zprofile, which is sourced with every login shell? The nature of environment variables is that they are inherited, so this would seem to be enough. If I need these variables in a cron job, I can execute it with