help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] The execution of /etc/bash.bashrc and ~/.bashrc for non


From: Greg Wooledge
Subject: Re: [Help-bash] The execution of /etc/bash.bashrc and ~/.bashrc for non interactive shells
Date: Thu, 30 Mar 2017 10:34:20 -0400
User-agent: Mutt/1.4.2.3i

On Thu, Mar 30, 2017 at 04:21:07PM +0200, Cristian Zoicas wrote:
> Can somebody explain the reasons behind the decision to allow
> bash to execute the files /etc/bash.bashrc and ~/.bashrc
> if it is started remotely and non interactively? For example
> the command
> 
>    ssh address@hidden echo "this is a test"
> 
> triggers the execution of the above mentioned files.

First of all, /etc/bash.bashrc (or similarly named files) are not used
by a default upstream bash.  There's a compile-time option to enable the
use of a system-wide bashrc file, and many Linux distributions turn
this on.  So I'm betting you're using a Linux distribution's build of
bash.

The decision to use bashrc (etc.) when bash is invoked interactively by
ssh goes back many years.  Here are some past threads talking about it:

https://lists.gnu.org/archive/html/bug-bash/2007-12/msg00000.html
https://lists.gnu.org/archive/html/bug-bash/2008-10/msg00051.html

And here is a comment from variables.c:

     /*
      * 24 October 2001
      *
      * I'm tired of the arguing and bug reports.  Bash now leaves SSH_CLIENT
      * and SSH2_CLIENT alone.  I'm going to rely on the shell_level check in
      * isnetconn() to avoid running the startup files more often than wanted.
      * That will, of course, only work if the user's login shell is bash, so
      * I've made that behavior conditional on SSH_SOURCE_BASHRC being defined
      * in config-top.h.
      */

I don't have any references older than this, to figure out where/when
the behavior originally started.  Maybe Chet remembers.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]