Greg Wooledge (12024-07-10): > 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.
What you describe is not legitimate, even semi-, these are hacks by people who cannot be bothered to organize their configuration properly. > 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. I save myself a lot of headaches by proper places for each snippet of configuration. Which I can do because I use zsh instead of bash. zshrc for interactive shell, zshenv for all shells, zprofile for interactive login shells, etc. We should not encourage people to pile hacks upon hacks. Regards, -- Nicolas George