Re: Reality check on bash behavior.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



akonstam@xxxxxxxxxxx wrote:
> I need to check that my observations on bash invocation is correct.
> In the bash man page it states that when the bash shell in invoked the
> following three files are sourced: /etc/profile, ~/.bash_profile and
> ~/.profile. My observation is that when .bash_profile is present
> .profile is not sourced.
> 
> This is in important to us because we have the same user directories 
> mounted on FC4 machines and OS X machines, On OS X machines it looks
> like .profile is sourced even when a .bash_profile exists.
> 
> I just want to check that my sanity is still in place and I am seeing
> what is really happening. I realize behavior on an OS X machine is off
> topic on a fedora list.

Good question!

man bash says:
   --noprofile
      Do  not read either the system-wide startup file /etc/profile or
      any  of  the  personal  initialization  files ~/.bash_profile,
      ~/.bash_login,  or  ~/.profile.   By  default,  bash reads these
      files when it is  invoked  as  a  login  shell  (see INVOCATION
      below).
then
   When  bash is invoked as an interactive login shell, or as a non-inter-
   active shell with the --login option, it first reads and executes com-
   mands  from  the file /etc/profile, if that file exists.  After reading
   that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
   in  that order, and reads and executes commands from the first one that
   exists and is readable.  The --noprofile option may be  used when  the
   shell is started to inhibit this behavior.

So your observations are consistent with documented behaviour on Fedora.
I understand that this is so users who are stuck with an earlier Bourne
shell can put bash in their .profile, create a .bash_profile, and things
will still work.

Unfortunately, I don't have access to an OS X machine.

It's possible that something in Apple's default /etc/profile or
~/.bash_profile is sourcing ~/.profile anyway. But a quick Google
suggests that this is not the case, and bash on OS X is not supposed to
run ~/.profile anyway if ~/.bash_profile exists. See, for example, Geoff
Lane's comments in
http://www.macosxhints.com/article.php?story=20030825001724805

(If it's the same Geoff Lane as I've come across elsewhere, he does seem
to know his stuff.)

Hope this helps,

James.
-- 
E-mail address: james | ... boxing the books up was a mistake: they are
@westexe.demon.co.uk  | welded to the floor through the power of gravity.
                      |     -- Telsa Gwynne's Diary.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux