zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Where PATH is set
Date: Tue, 05 Sep 2006 21:01:27 -0700	[thread overview]
Message-ID: <060905210127.ZM11470@torch.brasslantern.com> (raw)
In-Reply-To: <20060905183120.GA10848@cetus30.cs.utk.edu>

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.


  parent reply	other threads:[~2006-09-06  4:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-05 18:31 Chris Johnson
2006-09-05 21:08 ` William Scott
2006-09-06  4:01 ` Bart Schaefer [this message]
2006-09-06  6:16 ` Wayne Davison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=060905210127.ZM11470@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).