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

Re: PSA: Mac OS X El Capitan upgrade might break your $PATH



On Fri, Jul 31, 2015 at 11:53 AM, Mikael Magnusson <mikachu@xxxxxxxxx>
wrote:

> That's good news, they used to have that code in /etc/zshenv which
> meant you had _no_ way to override it. It only took them a few years
> to fix this.
>
> As a sidenote, it's not a great idea to set your path in .zshenv, you
> should probably move those settings to your .zprofile. (Otherwise,
> running a script that uses zsh will not use the $PATH from the
> environment, which can break things in some situations).
>

It's a trade-off. Back when ksh93 was my primary shell I had a ~/.environ
file where I put such things. Then I sourced that from ~/.profile and my
crontab entries. That way my cron jobs would have an environment consistent
with my interactive shells. Zsh's .zshenv makes things much easier. It also
means that when I do something like

ssh home "some_command"

that command gets the same environment it would have if I had gotten an
interactive shell and run the command.

I protect against the problem you mention by checking if PATH contains
$HOME/bin. If it does I assume it's already been initialized to a
reasonable value and leave it alone. If not I install my own PATH.

Of course this is only a problem if you shadow commands -- something most
people don't do. In my case I have wrappers around things like ssh in my
~/bin directory that I want to have precedence over the system supplied
version.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank


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