News for hackers. Stuff that matters.
Re:Stupid Unix Tricks by tremon on Thursday October 17, 2019 @09:22AM (#21281730)
as far as I can tell when I open new shells .profile isn't read

True, iff you have a .bash_profile. Bash only reads the first of ~/.bash_profile, ~/.bash_login, ~/.profile. It will ignore the rest of the list once it's found an existing file.

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.
Re:Stupid Unix Tricks by ashtonbaker on Thursday October 17, 2019 @09:50AM (#21282018)
This explains so many of my problems. Thank you.
Re:Stupid Unix Tricks by em500 on Thursday October 17, 2019 @02:45PM (#21285165)
https://hackernoon.com/bash-profile-vs-bashrc-vs-bin-bash-vs...

Note that in macOS every new Terminal (tab) opens a login shell, while most GUI Linux environments don't. (In Tmux/screen it depends on the configuration).