[oclug] .bash_profile/.bashrc (was: Re: [oclug] set $PATH)
Joe Burpee
jeb at burkby.com
Mon Jul 14 12:28:43 EDT 2003
On Mon, Jul 14, 2003 at 00:11:52 -0400, Patrick Smith wrote:
> Joe Burpee wrote:
> > On Thu, Jul 10, 2003 at 05:56:44PM -0400, Patrick Smith wrote:
> >>If you log in to X through xdm, ~/.bash_profile doesn't get run,
> >
> > It should, since Xsession should be exec-ing a login shell. (E.g.
> > RedHat's does.) Distro?
>
> I'm not using any distribution, but have a homebrew system with
> everything compiled from source. In particular, XFree86 4.3.0 with the
> ati.2 drivers from gatos.
Thanks for the explanation. IIRC the vanilla XFree86 startup stuff
comes with a recommendation that the administrator do some work on the
scripts, which I guess is what RedHat and other distros have done.
> There might be a case for exec'ing .xsession as a login shell.
It seems more to the point to me that there's a trivial case for
exec-ing a _login_ shell at _login_ time.
> But this
> isn't enough to get bash to source .bash_profile; the shell needs to be
> interactive as well,
That's news to me. Do you have a reference for that?
> and .xsession is not.
Well, since it's your script you could easily make it interactive with
`-i', if there were any need to do so. But I don't see the need.
> >>One solution would be to have ~/.xsession source ~/.bash_profile.
> >
> >This may be a bit unsafe since it causes the profile to be sourced
> >*after* the automatic sourcing of bashrc. It seems tidier (assuming
> >Xsession is broken and you can't fix it) just to run a login shell in
> >~/.xsession, which at least gets the sourcing order right.
>
> Since .xsession is not run interactively, I believe bash does sources
> neither .bash_profile nor .bashrc automatically.
I'm still not sure why you're basing this on non-interactivity. Since
your .xsession is not under a login shell, it seems pretty reasonable
that .bash_profile would not be sourced. And sourcing of `rc' files
depends on switches and environment variables. My only point was that
if the sourcing of bashrc (or perhaps some other script intended to
initialize a non-interactive shell) did occur implicitly (before the
first command in .xsession), then sourcing .bash_profile explicitly gets
things back-asswards. I guess I could have been more precise.
> >>Another is to make .bash_profile a symbolic link pointing to .bashrc.
> >
> >Aiiieeeee. I don't even want to think about that.
>
> Actually, this is what I do, and was doing long before I started using
> xdm. In my case, it works really nicely.
In my case it wouldn't, but that's beside the point. I just thought
that shell initialization was confused enough without muddying the
semantics further. I guess I'm being a bit of a purist. If it works
for you that's probably good enough.
Joe
More information about the OCLUG
mailing list