[gobolinux-devel] env vars in /etc/zprofile instead of zshrc
Jonatan Liljedahl
lijon at kymatica.com
Tue Apr 1 11:29:58 NZDT 2008
Michael Homer wrote:
> On Tue, Apr 1, 2008 at 10:58 AM, Jonatan Liljedahl <lijon at kymatica.com> wrote:
>> Michael Homer wrote:
>> > On Tue, Apr 1, 2008 at 10:27 AM, Jonatan Liljedahl <lijon at kymatica.com> wrote:
>> >> Nick Matteo wrote:
>> >> > On Mon, Mar 31, 2008 at 8:41 AM, Jonatan Liljedahl <lijon at kymatica.com> wrote:
>> ...
>>
>>>> > Moving everything to /etc/zprofile won't work because the main concern
>> >> > is to make sure it's loaded in all _interactive_ shells. (which
>> >> > zprofile isn't, it's only login shells; zshrc on the other hand is for
>> >> > exactly this.) You could have zshrc source zprofile, or you could
>> >> > just let scripts run in sh (which they pretty much all do) and leave
>> >> > the slim config running sh --login (which it does by default) and
>> >> > everything will be fine.
>> >>
>> >> No, zprofile is loaded for all login shells, and zshrc is loaded for
>> >> interactive shells *additionally*. So I really think that zshrc should
>> >> contain only stuff related to interactive shells, like prompt and
>> >> aliases, etc.. while important setup, variables (like PATH and programs
>> >> Environment files) should be in zprofile.
>> > Neither xterm nor any of its derivatives start login shells by
>> > default, so zprofile would not be loaded in them and mayn't have been
>> > beforehand. See the zsh guide for exactly what gets loaded when:
>> > http://zsh.sunsite.dk/Guide/zshguide02.html#l9
>>
>> Are you sure? When I start an xterm by simply typing 'xterm' in another
>> xterm, I get one with stuff from my ~/.zprofile loaded. In case it
>> inherits the variables from the parent xterm, then it's no problem
>> because it would do it also from other parent shells (like slims X session).
> Yes, I'm sure. Take a look at the docs (or stick an echo in your
> ~/.zprofile and see what you get output). I think there's an X
> resource you can set to make the -ls argument automatic, but I don't
> remember what it is.
You're right, an echo didn't show. So it must be that it inherited it.
> The path will be inherited from the parent shell, of course. That may
> not be zsh, though, so you're back to relying on whatever sh does.
Does it matter? If you're logged in you will (should) have the
environment variables there...
> Environment initialisation probably should be in the profile all the
> same, that's what it's meant for, but there are some obstacles to
> doing it that need to be considered first. To be honest, I'd probably
> be using sh or bash as the login command there anyway.
Regardless of what shell one has in their slim login command, I still
wonders: shouldn't the default gobo settings make zsh --login import the
Environent cache and other important env vars?
I still don't get the reason why env stuff shouldn't be in zprofile,
since it seems to work in all cases. (It *is* read by interactive shells
too, as promised in the zsh manpages)
>> In case of important environment variables, they could even be put in
>> zshenv which are read by all shells, login or not.
> That would probably be a bad idea. Then scripts will override the
> actual environment with what's in there every time.
Oh, yes. Didn't think about that.
--
/Jonatan [ http://kymatica.com ]
More information about the gobolinux-devel
mailing list