~/.bash_profile not source from symlinked login shell

1

If I call

bash --login

Then ~/.bash_profile is called. This seems as it should.

I also have /bin/sh symlinked to bash

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Jun 22  2017 /bin/sh -> bash

Calling

/bin/sh --login

Does not result in ~/.bash_profile being sourced. Instead ~/.profile gets sourced which may not include relevant bash specific things.

Is this how It should be? Is there a way to ensure ~/.bash_profile is called?

I'm running on Centos 6, with Bash 4.1.

Phil Rosenberg

Posted 2018-09-06T13:10:26.707

Reputation: 111

Answers

1

When bash is invoked as sh, it attempts to act as if it were a standard POSIX shell, so of course it doesn't source ~/.bash_profile. This is all documented; see man bash. If you want automatic sourcing of ~/.bash_profile, invoke it as bash.

varro

Posted 2018-09-06T13:10:26.707

Reputation: 179