This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: output allowed in .bashrc and .tcshrc (Was: Virus Found)
On Tuesday 11 Sep 01, Michael Schaap writes:
> Even .bashrc is only supposed to be called on interactive shells. (Unless
> BASH_ENV = "$HOME/.bashrc" which it really shouldn't, but seems to be
> commonly done.)
> Unfortunately, both "ssh machine command" and "scp ..." _do_ run
> .bashrc. I have no idea why, since
> ssh machine 'echo $-'
> shows that it is really a non-interactive shell.
It must be this, from the bash(1) man page:
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. ...
So the observed behavior is documented, with sshd in place of rshd.
> The documented way for Bash to check if a shell is interactive is by
> checking if $- contains 'i'. For example:
> if [[ $- = *i* ]] ; then
> echo Interactive
> fi
Thanks for the lesson!
Cheers,
David
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/