Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Message-Id: <5.1.0.14.2.20010911120619.00acb4a8@imap.local.mscha.com>
X-Sender: ml@imap.local.mscha.com (Unverified)
X-Mailer: QUALCOMM Windows Eudora Version 5.1
Date: Tue, 11 Sep 2001 12:10:40 +0200
To: cygwin@cygwin.com
From: Michael Schaap <cygwin@mscha.com>
Subject: Re: output allowed in .bashrc and .tcshrc (Was: Virus Found)
In-Reply-To: <7996-Tue11Sep2001104432+0100-starksb@ebi.ac.uk>
References: <20010911111946.A1285@cygbert.vinschen.de>
 <20010911004146.H937@cygbert.vinschen.de>
 <8F23E55D511AD5119A6800D0B76FDDE101A26A59@cpex3.channelpoint.com>
 <59jqpt4f25eochmtlslvv9nodngnkeeo3d@4ax.com>
 <5.1.0.14.2.20010911020929.00ac0fc0@imap.local.mscha.com>
 <20010911111946.A1285@cygbert.vinschen.de>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
X-Virus-Scanned: at mscha.org by amavisd-milter snapshot-20010714 (http://amavis.org/)

At 11:44 11-9-2001, David Starks-Browning wrote:
>On Tuesday 11 Sep 01, Corinna Vinschen writes:
> > ... If your login shell is bash and bash has been started by
> > rshd/sshd, it executes ~/.bashrc.  So the rule is, no output in
> > ~/.bashrc.

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.

> >
> > And, IIRC, the same rule applies for tcsh and ~/.cshrc.

Can't comment there, not a csh user


>Just to be precise and complete...
>
>That's almost correct.  Your *are* allowed to generate output in
>.bashrc (and in .cshrc for tcsh) for *interactive* shells only.  The
>usual way to test is to check for the existence of a prompt.  ($PS1 in
>bash, $prompt in tcsh.)  If no prompt is defined, you must not
>generate *any* output.

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

  - Michael

-- 
     I always wondered about the meaning of life.   So I looked it
     up in the dictionary under "L" and there it was - the meaning
     of life.  It was not what I expected.                  - Dogbert 


--
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/

