Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Where PATH is set
- X-seq: zsh-users 10687
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Where PATH is set
- Date: Tue, 05 Sep 2006 21:01:27 -0700
- In-reply-to: <20060905183120.GA10848@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060905183120.GA10848@xxxxxxxxxxxxxxxxxx>
On Sep 5, 2:31pm, Chris Johnson wrote:
}
} I have a political question I could use some help on. My system
} administrators currently set PATH in /etc/zshrc.
This is at least preferable to RedHat's idea of what belongs in that
file, which *still* includes "bindkey ' ' magic-space" and loading of
some files from /etc/profile.d/ that install aliases. My personal
opinion is that the only thing that belongs in /etc/zshrc is setting
the default shell prompt, and I'm a bit leery even of that.
In any case it's redundant to set something in /etc/zshenv and then
set it again in any other /etc/z* file. NOTHING stops /etc/zshenv
from being read; many things can bypass the rest of the files.
} The assignment is literal; no existing value is checked for. They
} assign the exact same thing to PATH in /etc/zshenv so that "ssh
} machine command" will work the same way.
Assigning PATH in /etc/zshenv is a perfectly reasonable thing to do,
particularly if important commands may reside in unexpected locations
like /opt/bin/ or even /usr/local/bin/. Most exported variables are
reasonable candidates for /etc/zshenv, but practially nothing else is,
except maybe resource limits.
} This setup forces me to similarly assign PATH twice, once in ~/.zshenv
} and once in ~/.zshrc.
You could always put "setopt NO_GLOBAL_RCS" in ~/.zshenv and cause all
the rest of the /etc files to be skipped. I used to do that, but those
/etc/profile.d/ files that annoy me so are unfortunately shared with
/etc/profile for bash, and therefore are are necessary to set up the
environment properly (e.g., for X11).
So, now, I do fun things like
builtin alias alias='[[ $0 = /etc/* ]] || \alias'
which renders the alias command a no-op when it appears in any file
under /etc/. If your sysadmins are doing
export PATH=....
then you could play the same trick with the export command; but more
likely they have the assignment and the export as separate steps.
} I think this is a horrible setup, a trap for inconsistencies just
} waiting to snare users, but the sysadmins think its a non-issue.
Sysadmins have a different set of priorities. They want to keep the
clueless from complaining, because it's much easier to deal with the
clueful -- even though you whine more, there aren't as many of you.
Put your PATH assignment (really, I hope it's a path assignment, the
array syntax is so much cleaner) in a third file, and "source" that
file from both ~/.zshenv and ~/.zshrc.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author