X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-5.3 required=5.0	tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_TX
X-Spam-Check-By: sourceware.org
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=google.com; s=20120113;        h=x-received:mime-version:sender:x-originating-ip:in-reply-to         :references:from:date:x-google-sender-auth:message-id:subject:to         :content-type:x-gm-message-state;        bh=pRvhCXSeJj+aj78qSC7Si11mJ5Lv+lVS6JiLMohssAE=;        b=jxvzDFkkqmhA16j3pt+FL/MxJnjrbnmenoEv85ylVALQg/J1Ya6ic80jlhCZecJU3H         Z9pCvrv0fGmvBrtcGwzcWwsY+nie/gHf3x3wVR0hK5BPK502NzujTLRcogbG7pAJ45Fa         +AGDoIHSa4WTHFBTY9Q6zUnX1k7qyE6f5w/3XsfuwK8UJVzuslP+T7LPzcS9HOixsJ0d         lZZRGoRzavina+28g/FDz2qC8VWPdclQv3VJUhiaRRlvR+B4gu0taCcsgGFrM5fPleKg         1Dq4VTdocP4egQMYLDwbOAlTvCb2YNNRvTk09NMYxwp17qLsevlFIdUkj1mCv6jZ4Gp1         IV0Q==
X-Received: by 10.194.156.170 with SMTP id wf10mr4823236wjb.25.1361979428240; Wed, 27 Feb 2013 07:37:08 -0800 (PST)
MIME-Version: 1.0
In-Reply-To: <26949.1361935259@relay.known.net>
References: <15470.1361923720@relay.known.net> <512D7040.7080905@gmail.com> <26949.1361935259@relay.known.net>
From: Robert Pendell <shinji+cygwin@elite-systems.org>
Date: Wed, 27 Feb 2013 10:36:38 -0500
Message-ID: <CAAeCd-MOwreUqsrwrYUT=JQwLzXrUCiMQOYqLsqF0+O0OLEc8A@mail.gmail.com>
Subject: Re: startxwin started bash does not read .bashrc or .bash_profile
To: cygwin@cygwin.com
Content-Type: text/plain; charset=UTF-8
X-Gm-Message-State: ALoCoQnikGUO9FRRdRvXyxQPvG2Vdl4xMwIlZ8QfwPmriXSNxS6lHeENTFGFMh9JBDzvQz09PIdp
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Tue, Feb 26, 2013 at 10:20 PM, Kevin Layer <> wrote:
> Arthur Tu wrote:
>
>>> On 2/27/2013 8:08 AM, Kevin Layer wrote:
>>> > If I put this into .startxwinrc:
>>> >
>>> >    mintty /usr/bin/bash.exe --login -i
>>> >
>>> > the resulting shell does not read .bash_profile.  If I put
>>> >
>>> >    mintty /usr/bin/bash.exe -i
>>> >
>>> > it doesn't read .bashrc.
>>> >
>>> >
>>> > I've been beating my head against this wall for hours, over a few
>>> > days.  I've googled my ass off, but I can't find anyone that's having
>>> > the same problem.
>>> >
>>> >
>>> > My ultimate goal is to use ssh-agent/ssh-add to make life easier, but
>>> > it requires my .bashrc to be sourced (.bash_profile merely sources
>>> > .bashrc).
>>> >
>>> >
>>> > Thanks.
>>> >
>>> >
>>> ## .bash_profile
>>> if [ -f "${HOME}/.bashrc" ] ; then
>>>   source "${HOME}/.bashrc"
>>> fi
>>>
>>> What do you mean? Isn't this enough?
>
> It is not.  As I said, without --login, when .bashrc would be loaded
> directly... it is *not*.
>
> This should be pretty easy for someone to test.  Does it work for
> anyone else, as I've described?
>
> I'm up to date on my installation as of today.
>

.bashrc and .bash_profile serve 2 different purposes.

.bash_profile is meant for login sessions (like ssh or a local terminal)
.bashrc is meant for non-login sessions (like scp)

Commonly .bash_profile does source in .bashrc so that it gets executed too.

BTW, You don't need to do --login and -i.  --login will assume -i anyways.

Dummy run on my linux box (I'll check cygwin later when I get a
chance) but this is for behavior check.

shinji@icarus:~$ bash --login
shinji@icarus:~$ echo $BASHRC
Y
shinji@icarus:~$ echo $BASH_PRO
Y
shinji@icarus:~$ exit
logout
shinji@icarus:~$ bash -i
shinji@icarus:~$ echo $BASHRC
Y
shinji@icarus:~$ echo $BASH_PRO

Note I placed an export statement in .bash_profile and .bashrc to mark
if they got executed. Note that on the login shell both did get
executed and on the non-login one (forced interactive) only .bashrc
was run.  .bashrc is sourced thanks to /etc/profile on my linux
system.

References:
http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
http://www.gnu.org/software/bash/manual/bashref.html#Invoking-Bash
Bash man page

Robert Pendell
A perfect world is one of chaos.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

