bug-bash
[Top][All Lists]
Advanced

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

Re: ~/.profile and ~/.bash_profile aren't executed on login


From: Chet Ramey
Subject: Re: ~/.profile and ~/.bash_profile aren't executed on login
Date: Mon, 11 Dec 2017 09:03:20 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 12/10/17 10:22 PM, Yuri wrote:
> On 12/10/17 13:51, Chet Ramey wrote:
>> You have not described a bug, since you have not demonstrated that bash is
>> behaving other than how it is documented, nor have you provided answers to
>> any of the questions you've been asked. You haven't even determined whether
>> or not bash is being invoked as a login shell at some unspecified point in
>> the mystery login sequence you're using.
> 
> 
> bash never calls ~/.profile when invoked as a login shell:
> 
> 
> cp ~/.profile ~/.profile.bak
> echo 'echo "==> executing ~/.profile"' > ~/.profile
> ln -s /usr/local/bin/bash /usr/local/bin/sh
> /usr/local/bin/sh --login
> ==> executing ~/.profile
> /usr/local/bin/bash --login
> 
> 
> It only calls ~/.profile when it is named 'sh'.

OK, this is progress. Bash, as documented, reads ~/.bash_profile first
when it's invoked as a login shell, falling back to ~/.bash_login and
~/.profile if it's not there. When it's called with the name `sh', it
reads ~/.profile. If you tried the same process with ~/.bash_profile,
you would see output.

This is documented in the INVOCATION section of the man page I referred
to in an earlier message.

> You should stop depending on sh being linked to bash. It should never
> examine its name, and act as a login shell with any name.

The use of `sh' to trigger reading ~/.profile is only a concession to
historical compatibility -- Posix does not require it. Bash has always
preferred ~/.bash_profile when invoked as a login shell. This behavior
dates back to the very earliest versions.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]