This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: startxwin started bash does not read .bashrc or .bash_profile


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]