bug-bash
[Top][All Lists]
Advanced

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

Re: why does bash not execute .bashrc with ssh -t ?


From: Chet Ramey
Subject: Re: why does bash not execute .bashrc with ssh -t ?
Date: Tue, 14 Oct 2008 22:24:28 -0400
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Jon Seymour wrote:

>     Bash attempts to determine when it is being run by the remote shell
> daemon, usually rshd.  If bash determines it is being run by rshd, it
> reads  and  executes
>     commands  from  ~/.bashrc,  if that file exists and is readable.  It
> will not do this if invoked as sh.  The --norc option may be used to inhibit
> this behavior, and
>     the --rcfile option may be used to force another file to be read, but
> rshd does not generally invoke the shell with those options or allow them to
> be specified.
> 
> However, when I use the ssh -t option, it would seem that allocation of a
> pseudo-tty is causing bash to assume that it is not being invoked by a
> remote shell daemon.

Correct.  One of the criteria bash uses to decide whether it's being
invoked by rshd or sshd is that its stdin is a socket.  Allocating a
pseudo-tty makes that false.

You can force bash to source .bashrc when it finds the various ssh
variables in its startup environment by defining SSH_SOURCE_BASHRC
in config-top.h and rebuilding bash.  That will cause .bashrc to be
sourced more times than it should, but it will catch the cases you
are interested in.

Chet

> 
> Is there any way I can have an ssh pseudo-tty and get bash to execute
> ~/.bashrc?
> 
> jon seymour.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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