This is the mail archive of the cygwin-apps mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ITA] - base-files

On Fri, Dec 10, 2010 at 06:50:32AM +0000, Andy Koppe wrote:
> On 10 December 2010 00:05, David Sastre wrote:
> Speaking of /etc/profile.d, it seems wrong to do that from
> /etc/bash.bashrc. The name of the directory suggests that its content
> is for login shells only.

Absolutely. I'll try selective sourcing from /etc/profile e.g. bash sources 
*sh, and not *.zsh, and viceversa.

> >> > A bash login shell only
> >> > automatically sources the *profile files, not the *bashrc files. Users
> >> > have every right to customise their ~/.bash_profile and ~/.bashrc to
> >> > death, or to just delete them. Or perhaps they didn't have them in the
> >> > first place because they nominated an existing directory as their home
> >> > without copying the skel files. So there's no guarantee that ~/.bashrc
> >> > and /etc/bash.bashrc are sourced by a bash login shell.

This is important. The conclusion of this reasoning is that users'
personal files (~/.bash{rc,_profile}) shouldn't be trusted at all in
order to define a system-wide configuration. That's what happens both in my
proposal and in the current base-files. (See below for a possible solution)

> > That's true. Unless sourced from /etc/profile. Would that be
> > acceptable?
> I think that would make sense, but it should only do so when the shell
> is an interactive login shell. Here's how to find out:

If you propose to check for *i* in $- instead of PS1 (as I'm doing now), 
yeah, it does look more reliable.

> Zsh sources *profile files in login shells and the *zshrc files in
> interactive shells, so an interactive login shell sources both.

Not in bash. This is an example of a login shell. I have commented out
the code that sources /etc/bash.bashrc and ~/.bashrc from

$ grep MY_TEST /etc/profile /etc/bash.bashrc .bashrc .bash_profile
$ echo $MY_TEST
$ echo $-

(Erm...I just realized know that was _exactly_ your point, was it?)

> Hence
> stuff that needs to be done once at login (e.g. setting up paths) goes
> into *profile, and stuff to make an interactive shell comfortable
> (e.g. prompt and aliases) goes into *zshrc. I think that makes plenty
> of sense.

It does, indeed.

> Bash isn't going to change in this respect though, so emulating it by
> /etc/profile sourcing /etc/bash.bashrc and ~/.bash_profile sourcing
> ~/.bashrc is the next best thing.

I learnt that enabling /etc/bash.bashrc to be sourced as a system-wide *rc 
file can be defined in a header file in the bash sources, and also
/etc/bash.bash_logout, BTW.
I'm sending a request to enable both of them to the bash mantainer;
if he agrees to include them, it would be easier for me to define
a system-wide configuration layer that doesn't interfere with (neither
depend on) users' custom files, and also, presumably, allows smoother updates 
from there on.

> > ?- There must be a switch for bash/mksh/* 
> Wasn't there a patch for doing that switch without forks?

Not that I know of... I'll try to write it down, though.

Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

Attachment: signature.asc
Description: Digital signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]