Re:Stupid Unix Tricks
by jolmg on Thursday October 17, 2019 @11:43AM
(#21283243)
Still, they're not read with every new interactive shell. They're read only with login shells. From the manual:
> When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login,
> When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc
So, this is wrong:
> bashrc refers to something that runs in each and every new shell
Because .bashrc doesn't run when you execute a shell script, and doesn't run when you use `bash -c`.
And this is wrong:
> profile refers to something that runs only in interactive shells
Because it does run in non-interactive shells when they're login shells, and because it implies that it runs in every interactive shell, which it doesn't. It only runs in login shells.
Re:Stupid Unix Tricks
by lloeki on Saturday October 19, 2019 @05:05AM
(#21297558)
Insanely enough, this is set up wrong in Debian and derivatives, where bash_profile sources bashrc as a default from /etc/skel, leading to damning "not a tty" messages because at some point it calls some tty requiring command unconditionally.
> When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login,
> When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc
So, this is wrong:
> bashrc refers to something that runs in each and every new shell
Because .bashrc doesn't run when you execute a shell script, and doesn't run when you use `bash -c`.
And this is wrong:
> profile refers to something that runs only in interactive shells
Because it does run in non-interactive shells when they're login shells, and because it implies that it runs in every interactive shell, which it doesn't. It only runs in login shells.