bug-bash
[Top][All Lists]
Advanced

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

.bashrc is sourced even for non-interactive shells (when run from sshd)


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

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]