bug-bash
[Top][All Lists]
Advanced

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

Re: .bashrc is sourced even for non-interactive shells (when run from ss


From: Mikel Ward
Subject: Re: .bashrc is sourced even for non-interactive shells (when run from sshd)
Date: Sat, 2 Jun 2012 10:19:57 -0700

Apologies.  It's mentioned a few paragraphs further down.

Can I suggest a change?

How about instead of:

       When an interactive shell that is not a login shell is started

something like:

       When a shell is started that is not a login shell, but is
either an interactive shell or a network shell

On Sat, Jun 2, 2012 at 10:15 AM, Mikel Ward <mikel@mikelward.com> wrote:
> bash sources .bashrc even for some non-interactive shells.
>
> For example with
>
>    echo \$- is $-
>
> in ~/.bashrc, and shell set to /bin/bash (bash 4.2.28)
>
>    ssh -n -T localhost true
>
> produces the output
>
>    $- is hBc
>
> I assume this is caused by this code in shell.c
>
>     if (run_by_ssh || isnetconn (fileno (stdin)))
>
> The man page says
>
>       When an interactive shell that is not a login shell is started,
> bash reads and executes commands from ~/.bashrc,
>
> but makes no mention of the special handling for ssh and rsh.
>
> This seems to have been the case since at least bash 2.02.
>
> I'd argue this is a misfeature, but I guess that ship has sailed.  Can
> the man page at least be updated?
>
> Thanks



reply via email to

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