An inexplicable omission in bash's sourcing of
I discovered recently that I missed a case in my writeup of when
bash sources your
.bashrc, or technically I didn't
miss a case because bash has an inexplicable omission: bash doesn't
.bashrc when you ssh in with a pty. That is, if you
ssh -t host command ...
.bashrc is not sourced. Neither does bash source your
(well, of course).
This was an unpleasant surprise when I found it out recently, since on
some of our systems we use ssh to do things that we want to interact
with, and they involve commands that are not on the default
until recently I was counting on
.bashrc to fix up that problem, which
is how I came to discover the issue. (There's nothing like actually
trying your plans out.)
I assume that this is caused by a misfire in the bash heuristics that try to figure out if you are ssh'ing in. Hopefully this means that it will be fixed in the future (although some of the systems affected by this are Solaris machines, which are unlikely to get new versions of bash any time soon).
(Although it might be tempting to see this as an argument against such
heuristics in general, I don't agree with that position. For better
or worse, bash's heuristics to source
.bashrc when you ssh in give
you generally useful behavior. And taking away features entirely just
because they can't be implemented perfectly is not generally very
Comments on this page:Written on 03 May 2009.