On Wed, Jul 10, 2024 at 16:27:16 +0200, Nicolas George wrote:
> David Wright (12024-07-10):
> > Someone might source .bashrc from a binary in order to
> > access functions that are defined within it.
> 
> That would be shooting oneself in the foot. No need to cater for them.

There are many legitimate or semi-legitimate situations where a .bashrc
file might be read by a shell that's not running inside a terminal.

One of them is if someone chooses to dot in ~/.profile from their
~/.xsession file, or something analogous to it.  Or perhaps their
operating system does this automatically in certain kinds of login.

Another might be a scripted ssh session being run from cron, or some
other parent that's not in a terminal.  Analogously, the ancient
predecessors of ssh (rsh, rexec) had exactly the same issues.

When adding new commands to your shell dot files, always wrap commands
that assume/require the presence of a terminal in a check for a terminal.
You'll save yourself a *lot* of headaches.

Reply via email to