In Linux and, to my knowledge, all Unix systems, terminal emulators run interactive, non-login shells by default. This means that, for bash, the started shell will:
When an interactive shell that is not a login shell is started, bash reads and executes commands from
~/.bashrc, if these files exist. This may be inhibited by using the
--rcfilefile option will force bash to read and execute commands from file instead of
And for login shells:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the
--loginoption, it first reads and executes commands from the file
/etc/profile, if that file exists. After reading that file, it looks for
~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
--noprofileoption may be used when the shell is started to inhibit this behavior.
On OSX, however, the default shell (which is bash) started in the default terminal (Terminal.app) actually sources
~.profile etc. In other words, it acts like a login shell.
Main question: Why is the default interactive shell a login shell on OSX? Why did OSX choose to do this? This means that all instructions/tutorials for shell based things that mention changing things in
~/.bashrc will fail on OSX or vice versa for
~/.profile. Still, while many accusations can be leveled at Apple, hiring incompetent or idiotic devs is not one of them. Presumably, they had a good reason for this, so why?
Subquestions: Does Terminal.app actually run an interactive login shell or have they changed bash's behavior? Is this specific to Terminal.app or is it independent of the terminal emulator?