public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: startxwin started bash does not read .bashrc or .bash_profile
@ 2013-02-27 22:45 Kevin Layer
  0 siblings, 0 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 22:45 UTC (permalink / raw)
  To: cygwin

Btw, this happens on my home and work systems.  Both Windows 7
Ultimate x64.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-03-01 16:13                     ` Chris J. Breisch
@ 2013-03-01 17:35                       ` Andrey Repin
  0 siblings, 0 replies; 26+ messages in thread
From: Andrey Repin @ 2013-03-01 17:35 UTC (permalink / raw)
  To: Chris J. Breisch, cygwin

Greetings, Chris J. Breisch!

> On 3/1/2013 10:49 AM, Kevin Layer wrote:
>>
>> Don't have cron running.  I start it as me, the logged in user, from a
>> mouse click or running "startxwin" in a mintty.  Behaves the same
>> either way.

> Well, I am unable to duplicate this no matter what I do. I have even 
> launched a dash shell directly from cmd.exe and done a startxwin from that.

> I do have the following additions at the beginning of my .bashrc and 
> .bash_profile

> .bashrc:

> [[ "$-" != *i* ]] && return
> export BASHRC=${HOME}/.bashrc
> if [ "${BASH_PROFILE-unset}" = "unset" ]; then
>      source ${HOME}/.bash_profile
> fi

That's a weird way of doing this, if you ask me...
Normally (or, "in the Linux distributions I've been able to check"), .profile
sourcing the .bashrc.
The solution would be to launch bash with --rcfile=~/.profile

> .bash_profile:
> export BASH_PROFILE=${HOME}/.bash_profile
> if [ -f "${HOME}/.bashrc" ] ; then
>    if [ "${BASHRC-unset}" = "unset" ]; then
>      source "${HOME}/.bashrc"
>    fi
> fi

This is even weirder way of doing things.

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

Naturally, if you start with --rcfile set to .profile, your normal rcfile will
still be included.

> That's a little bit of overkill, but it ensures that both my 
> .bash_profile and .bashrc are sourced if I am in an interactive shell.

I'm unsure of the origin of this mess, but it's really should not be an issue.
Probably need to investigate whole chain, that leading to the bash being
started without .profile being run at least once in the meantime.

> For consistency, I should do a check for existence of the .bash_profile 
> before I source it in the .bashrc, just as I do with the .bashrc in 
> .bash_profile. But from a purist standpoint that's hardly the only thing 
> I'm doing wrong here.

> I do not have an .xinitrc. I do have an .Xdefaults, but it just has some 
> xterm display stuff in it.


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 01.03.2013, <21:19>

Sorry for my terrible english...


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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-03-01 15:49                   ` Kevin Layer
@ 2013-03-01 16:13                     ` Chris J. Breisch
  2013-03-01 17:35                       ` Andrey Repin
  0 siblings, 1 reply; 26+ messages in thread
From: Chris J. Breisch @ 2013-03-01 16:13 UTC (permalink / raw)
  To: cygwin

On 3/1/2013 10:49 AM, Kevin Layer wrote:
>
> Don't have cron running.  I start it as me, the logged in user, from a
> mouse click or running "startxwin" in a mintty.  Behaves the same
> either way.

Well, I am unable to duplicate this no matter what I do. I have even 
launched a dash shell directly from cmd.exe and done a startxwin from that.

I do have the following additions at the beginning of my .bashrc and 
.bash_profile

.bashrc:

[[ "$-" != *i* ]] && return
export BASHRC=${HOME}/.bashrc
if [ "${BASH_PROFILE-unset}" = "unset" ]; then
     source ${HOME}/.bash_profile
fi

.bash_profile:
export BASH_PROFILE=${HOME}/.bash_profile
if [ -f "${HOME}/.bashrc" ] ; then
   if [ "${BASHRC-unset}" = "unset" ]; then
     source "${HOME}/.bashrc"
   fi
fi

That's a little bit of overkill, but it ensures that both my 
.bash_profile and .bashrc are sourced if I am in an interactive shell. 
For consistency, I should do a check for existence of the .bash_profile 
before I source it in the .bashrc, just as I do with the .bashrc in 
.bash_profile. But from a purist standpoint that's hardly the only thing 
I'm doing wrong here.

I do not have an .xinitrc. I do have an .Xdefaults, but it just has some 
xterm display stuff in it.

Chris

-- 
In theory, there's no difference between theory and practice. In 
practice, there is.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-03-01 14:11                 ` Earnie Boyd
@ 2013-03-01 15:49                   ` Kevin Layer
  2013-03-01 16:13                     ` Chris J. Breisch
  0 siblings, 1 reply; 26+ messages in thread
From: Kevin Layer @ 2013-03-01 15:49 UTC (permalink / raw)
  To: cygwin

Earnie Boyd wrote:

>> >>> Then what is the value of $SHELL?
>> >
>> > /bin/bash
>> 
>> What user actually starts the session?  I've seen this type of thing
>> when the cron daemon starts a session.  The profile files are never
>> read.

Don't have cron running.  I start it as me, the logged in user, from a
mouse click or running "startxwin" in a mintty.  Behaves the same
either way.


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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-28 14:28               ` Kevin Layer
@ 2013-03-01 14:11                 ` Earnie Boyd
  2013-03-01 15:49                   ` Kevin Layer
  0 siblings, 1 reply; 26+ messages in thread
From: Earnie Boyd @ 2013-03-01 14:11 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 28, 2013 at 9:28 AM, Kevin Layer wrote:
> Earnie Boyd wrote:
>
>>> On Wed, Feb 27, 2013 at 5:16 PM, Kevin Layer wrote:
>>> >
>>> > Did you read the original report and all the replies in the chain?
>>> >
>>> >    ...it requires my .bashrc to be sourced (.bash_profile merely sources
>>> >    .bashrc).
>>>
>>> Then what is the value of $SHELL?
>
> /bin/bash

What user actually starts the session?  I've seen this type of thing
when the cron daemon starts a session.  The profile files are never
read.

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-28 13:24             ` Earnie Boyd
@ 2013-02-28 14:28               ` Kevin Layer
  2013-03-01 14:11                 ` Earnie Boyd
  0 siblings, 1 reply; 26+ messages in thread
From: Kevin Layer @ 2013-02-28 14:28 UTC (permalink / raw)
  To: cygwin

Earnie Boyd wrote:

>> On Wed, Feb 27, 2013 at 5:16 PM, Kevin Layer wrote:
>> >
>> > Did you read the original report and all the replies in the chain?
>> >
>> >    ...it requires my .bashrc to be sourced (.bash_profile merely sources
>> >    .bashrc).
>> 
>> Then what is the value of $SHELL?

/bin/bash

>> 
>> -- 
>> Earnie
>> -- https://sites.google.com/site/earnieboyd
>> 
>> --
>> 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

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 22:16           ` Kevin Layer
@ 2013-02-28 13:24             ` Earnie Boyd
  2013-02-28 14:28               ` Kevin Layer
  0 siblings, 1 reply; 26+ messages in thread
From: Earnie Boyd @ 2013-02-28 13:24 UTC (permalink / raw)
  To: cygwin

On Wed, Feb 27, 2013 at 5:16 PM, Kevin Layer wrote:
>
> Did you read the original report and all the replies in the chain?
>
>    ...it requires my .bashrc to be sourced (.bash_profile merely sources
>    .bashrc).

Then what is the value of $SHELL?

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 17:11         ` K Stahl
  2013-02-27 18:07           ` Kevin Layer
  2013-02-27 22:19           ` Kevin Layer
@ 2013-02-27 23:14           ` Kevin Layer
  2 siblings, 0 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 23:14 UTC (permalink / raw)
  To: cygwin

Also, strace'ing startxwin was not fruitful--the program hangs without
putting up any windows or doing much work at all.  <sigh>

I'm open to more suggestions...

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 17:11         ` K Stahl
  2013-02-27 18:07           ` Kevin Layer
@ 2013-02-27 22:19           ` Kevin Layer
  2013-02-27 23:14           ` Kevin Layer
  2 siblings, 0 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 22:19 UTC (permalink / raw)
  To: cygwin

K Stahl wrote:

>> I normally start a terminal in my .xinitrc file (Place it in your home
>> directory):
>> 
>> Example:
>> 
>> #!/usr/bin/sh
>> urxvt -e bash -l & wmpid=$!
>> wait ${wmpid}

Turns out, I'm mistaken, but I found out something interesting.

I had created a .xinitrc with a single "xterm" call in it, but I was
still running startxwin.exe instead of xinit.exe, so because I had
renamed .startxwinrc to .startxwinrc.disabled, I was running with some
default init file for startxwin.exe.

The xterm that comes up in this case *does* source my .bashrc.

From the man page:

       startxwin
               This  will  start  up  an  XWin  server  and  run  the   user's
               .startxwinrc, if it exists, or else start an xterm.


So, the question is, why does the xterm that is started in the "or
else" behave different than the one started from .startxwinrc?

A big mystery to me.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 21:17         ` Earnie Boyd
@ 2013-02-27 22:16           ` Kevin Layer
  2013-02-28 13:24             ` Earnie Boyd
  0 siblings, 1 reply; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 22:16 UTC (permalink / raw)
  To: cygwin

Earnie Boyd wrote:

>> On Wed, Feb 27, 2013 at 3:15 PM, Kevin Layer wrote:
>> > That was one of the experiments I did, and I saw no evidence that any
>> > commands were executed.  I even passed it as the argument to the
>> > invocation.
>> >
>> > As for the assumption, I understand that an error could have
>> > short-circuited the processing of my init file, but in the bash's that
>> > haven't read it,
>> >
>> >    . .bashrc
>> >
>> > produces no errors *and* has my aliases and new prompt.
>> 
>> $HOME/.bashrc isn't always read.  It depends on how bash is executed.
>> If this is a --login you need $HOME/.bash_profile that sources
>> $HOME/.bashrc.

Did you read the original report and all the replies in the chain?

   ...it requires my .bashrc to be sourced (.bash_profile merely sources
   .bashrc).


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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 20:15       ` Kevin Layer
@ 2013-02-27 21:17         ` Earnie Boyd
  2013-02-27 22:16           ` Kevin Layer
  0 siblings, 1 reply; 26+ messages in thread
From: Earnie Boyd @ 2013-02-27 21:17 UTC (permalink / raw)
  To: cygwin

On Wed, Feb 27, 2013 at 3:15 PM, Kevin Layer wrote:
> That was one of the experiments I did, and I saw no evidence that any
> commands were executed.  I even passed it as the argument to the
> invocation.
>
> As for the assumption, I understand that an error could have
> short-circuited the processing of my init file, but in the bash's that
> haven't read it,
>
>    . .bashrc
>
> produces no errors *and* has my aliases and new prompt.

$HOME/.bashrc isn't always read.  It depends on how bash is executed.
If this is a --login you need $HOME/.bash_profile that sources
$HOME/.bashrc.

http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Bash-Startup-Files

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 19:50     ` Andrey Repin
  2013-02-27 20:09       ` Christopher Faylor
@ 2013-02-27 20:15       ` Kevin Layer
  2013-02-27 21:17         ` Earnie Boyd
  1 sibling, 1 reply; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 20:15 UTC (permalink / raw)
  To: cygwin

Andrey Repin wrote:

>> Greetings, Kevin Layer!
>> 
>> > I know ~/.bashrc hasn't been read because my prompt is not changed and
>> > my aliases are not there.
>> 
>> That's just assumption. Not the first-hand knowledge. It may be true, or
>> not... Best way to know is to place
>> set -x
>> around the start of the file and observe the results.

That was one of the experiments I did, and I saw no evidence that any
commands were executed.  I even passed it as the argument to the
invocation.

As for the assumption, I understand that an error could have
short-circuited the processing of my init file, but in the bash's that
haven't read it, 

   . .bashrc

produces no errors *and* has my aliases and new prompt.

Kevin

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 19:50     ` Andrey Repin
@ 2013-02-27 20:09       ` Christopher Faylor
  2013-02-27 20:15       ` Kevin Layer
  1 sibling, 0 replies; 26+ messages in thread
From: Christopher Faylor @ 2013-02-27 20:09 UTC (permalink / raw)
  To: cygwin

On Wed, Feb 27, 2013 at 11:37:52PM +0400, Andrey Repin wrote:
>Greetings, Kevin Layer!
>
>> I know ~/.bashrc hasn't been read because my prompt is not changed and
>> my aliases are not there.
>
>That's just assumption. Not the first-hand knowledge. It may be true, or
>not... Best way to know is to place
>set -x
>around the start of the file and observe the results.
>
>>>> This is also a really odd place to start mintty.  Why start it as a side
>>>> effect of the unrelated action starting the X server?
>
>> This is merely an example, the simplest one to reproduce the failure.
>> It's not how I want to use startxwin.
>
>>>> > 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).
>>>> 
>>>> If you are going to work with both mintty and X clients, which will not
>>>> naturally have a common parent ssh-agent process to inherit from, you might
>>>> want to investigate the keychain package.
>
>> I'm unfamiliar with that.  Thanks for the pointer.
>
>Or simply use PuTTY and PageAnt.

**cgf checks the mailing list

Yep.  It really is the cygwin mailing list.

If someone is here, it is presumed that they want to use Cygwin so suggesting
non-Cygwin alternatives is really off-topic and )adjective deleted(.

cgf

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 17:59   ` Kevin Layer
@ 2013-02-27 19:50     ` Andrey Repin
  2013-02-27 20:09       ` Christopher Faylor
  2013-02-27 20:15       ` Kevin Layer
  0 siblings, 2 replies; 26+ messages in thread
From: Andrey Repin @ 2013-02-27 19:50 UTC (permalink / raw)
  To: Kevin Layer, cygwin

Greetings, Kevin Layer!

> I know ~/.bashrc hasn't been read because my prompt is not changed and
> my aliases are not there.

That's just assumption. Not the first-hand knowledge. It may be true, or
not... Best way to know is to place
set -x
around the start of the file and observe the results.

>>> This is also a really odd place to start mintty.  Why start it as a side
>>> effect of the unrelated action starting the X server?

> This is merely an example, the simplest one to reproduce the failure.
> It's not how I want to use startxwin.

>>> > 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).
>>> 
>>> If you are going to work with both mintty and X clients, which will not
>>> naturally have a common parent ssh-agent process to inherit from, you might
>>> want to investigate the keychain package.

> I'm unfamiliar with that.  Thanks for the pointer.

Or simply use PuTTY and PageAnt.


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 27.02.2013, <23:35>

Sorry for my terrible english...


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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 17:11         ` K Stahl
@ 2013-02-27 18:07           ` Kevin Layer
  2013-02-27 22:19           ` Kevin Layer
  2013-02-27 23:14           ` Kevin Layer
  2 siblings, 0 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 18:07 UTC (permalink / raw)
  To: cygwin

K Stahl wrote:

>> I normally start a terminal in my .xinitrc file (Place it in your home
>> directory):
>> 
>> Example:
>> 
>> #!/usr/bin/sh
>> urxvt -e bash -l & wmpid=$!
>> wait ${wmpid}

Bash started via .xinitrc *does* read my .bashrc.  Interesting!

I'll play more with this tonight to see if I can get my ssh-agent/add
setup working with .xinitrc instead of .startxwinrc.

Thanks!

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 17:55 ` Jon TURNEY
@ 2013-02-27 17:59   ` Kevin Layer
  2013-02-27 19:50     ` Andrey Repin
  0 siblings, 1 reply; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 17:59 UTC (permalink / raw)
  To: cygwin

Jon TURNEY wrote:

>> On 27/02/2013 00:08, 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 tried to reproduce this, but it seem to work ok for me.
>> 
>> How can are you checking if ~/.bashrc has been read? Have you tried using bash
>> -v to check what bash is reading?

I know ~/.bashrc hasn't been read because my prompt is not changed and
my aliases are not there.

>> This is also a really odd place to start mintty.  Why start it as a side
>> effect of the unrelated action starting the X server?

This is merely an example, the simplest one to reproduce the failure.
It's not how I want to use startxwin.

>> > 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).
>> 
>> If you are going to work with both mintty and X clients, which will not
>> naturally have a common parent ssh-agent process to inherit from, you might
>> want to investigate the keychain package.

I'm unfamiliar with that.  Thanks for the pointer.

Kevin

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27  0:08 Kevin Layer
  2013-02-27  2:32 ` Arthur Tu
@ 2013-02-27 17:55 ` Jon TURNEY
  2013-02-27 17:59   ` Kevin Layer
  1 sibling, 1 reply; 26+ messages in thread
From: Jon TURNEY @ 2013-02-27 17:55 UTC (permalink / raw)
  To: cygwin; +Cc: layer

On 27/02/2013 00:08, 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 tried to reproduce this, but it seem to work ok for me.

How can are you checking if ~/.bashrc has been read? Have you tried using bash
-v to check what bash is reading?

This is also a really odd place to start mintty.  Why start it as a side
effect of the unrelated action starting the X server?

> 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).

If you are going to work with both mintty and X clients, which will not
naturally have a common parent ssh-agent process to inherit from, you might
want to investigate the keychain package.


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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 16:20       ` Kevin Layer
@ 2013-02-27 17:11         ` K Stahl
  2013-02-27 18:07           ` Kevin Layer
                             ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: K Stahl @ 2013-02-27 17:11 UTC (permalink / raw)
  To: cygwin

I normally start a terminal in my .xinitrc file (Place it in your home
directory):

Example:

#!/usr/bin/sh
urxvt -e bash -l & wmpid=$!
wait ${wmpid}

Using this scheme, I haven't had the issues the original poster has described.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 16:08     ` Eliot Moss
@ 2013-02-27 16:20       ` Kevin Layer
  2013-02-27 17:11         ` K Stahl
  0 siblings, 1 reply; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 16:20 UTC (permalink / raw)
  To: cygwin

Eliot, thanks for the reply.

The passwd/group was an interesting thought.  Unfortunately:

@oob2$ mkpasswd -l > passwd.new
@oob2$ diff passwd passwd.new
@oob2$ mkgroup -l > group.new
@oob2$ diff group group.new
@oob2$ 


It's not just mintty.  When I run xterm, it doesn't source any of my
init files, either.

This is not a new issue.  I only started to care about it recently
because I want to use ssh-agent/ssh-add in my .bashrc/.bash_profile.

As for PATH, it's set so that it can find the programs, so I'm pretty
sure that's neither here nor there.

More ideas for debugging?

Here's my mount output, in case that might be relevant:

bash-4.1$ mount
C:/cygwin/home on /home type ntfs (binary)
C:/cygwin/bin on /usr/bin type ntfs (binary,noacl)
C:/cygwin/lib on /usr/lib type ntfs (binary,noacl)
C:/cygwin on / type ntfs (binary,noacl)
C: on /c type ntfs (binary,noacl,posix=0,user)
D: on /d type ntfs (binary,noacl,posix=0,user)
E: on /e type vfat (binary,noacl,posix=0,user)
Y: on /cygdrive/y type smbfs (binary,noacl,posix=0,user,noumount,auto)
Z: on /cygdrive/z type ntfs (binary,noacl,posix=0,user,noumount,auto)
bash-4.1$ 

Note that I added the /home entry to get `noacl' out of the options.
However, this is a new thing, and as I said, the problem is old.

Thanks.

Kevin

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27  3:21   ` Kevin Layer
  2013-02-27 15:37     ` Robert Pendell
@ 2013-02-27 16:08     ` Eliot Moss
  2013-02-27 16:20       ` Kevin Layer
  1 sibling, 1 reply; 26+ messages in thread
From: Eliot Moss @ 2013-02-27 16:08 UTC (permalink / raw)
  To: cygwin

Dear Kevin (et al.) -- I use StartXWin all the time,
and start bash from an xterm, and the startup reading
of .bash_profile, etc., proceeds as documented.

Thinking it might be something about mintty, I tested
that as well, with --login and with just -i, and it
all works as expected, reading the proper startup
files.

Two things occur to me.  One is that I struggle some
with .startxwinrc, etc., until I realized that my
usual scripts have not been run so my usual paths are
not set.  I needed an explicit setting of PATH in my
.startxwinrc file, like this:

PATH="${PATH}:/usr/bin"

However, if mintty and bash are both running, then that
is probably not your issue.

What I do wonder about is the setting of HOME.  In your
email you wrote out *Windows* versions of the paths.
My HOME reads /home/Eliot when I do echo $HOME in bash.
While cygwin can use Windows paths in some cases, the
whole situation can be sensitive and surprising.

So this also leads me to wonder if you have the cygwin
passwd and group files set up right.  You might want to
look into /etc/passwd and /etc/group.  See the programs
mkpasswd and mkgroup, which are there to help build
proper versions of those files.

Finally, did this start as a result of an upgrade of
cygwin or of cygwin X server related programs or files?
That would be a helpful clue (to the maintainers, not
to me :-) ).

Regards -- Eliot

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 15:37     ` Robert Pendell
  2013-02-27 15:44       ` Eliot Moss
@ 2013-02-27 15:50       ` Kevin Layer
  1 sibling, 0 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27 15:50 UTC (permalink / raw)
  To: cygwin

Robert Pendell wrote:

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

Exactly what mine does.  I just want to be clear: I have not been able
to get bash to source *anything* when started from startxwin.exe.

I've done hours of experimentation and done many variations on how
bash is started (from mintty, xterm, urxvt, ...) and I've not found a
single working case.   I've passed --init-file and --rcfile explicity.

I've strace'd the startup of bash and only ever saw it open
.bash_history.  No touches to the init files.   (I don't know how good
strace is on cygwin, so this might not be definitive.)

Can anyone else get their init file(s) loaded?? 

This seems like a serious bug.

Btw, I set HOME in Windows to c:\cygwin\home\layer and not c:\Users\layer\.
*BUT*, I have put in place dummy .bash_profile and .bashrc files that
echo something and I've not seen that trigger during testing.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27 15:37     ` Robert Pendell
@ 2013-02-27 15:44       ` Eliot Moss
  2013-02-27 15:50       ` Kevin Layer
  1 sibling, 0 replies; 26+ messages in thread
From: Eliot Moss @ 2013-02-27 15:44 UTC (permalink / raw)
  To: cygwin

On 2/27/2013 10:36 AM, Robert Pendell wrote:

Dear Robert -- I think the original poster's
concern was not the general working of bash
with .bash_profile and .bashrc, but the
specific behavior when bash is started by
an instance of mintty which itself is started
by the X windows server in .startxwinrc -- a
behavior that seems at variance with the normal
bash startup behavior.

My sense of what you wrote was that it
reported testing running a new bash from bash,
which is not the situation of concern ...

Regards -- Eliot Moss

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27  3:21   ` Kevin Layer
@ 2013-02-27 15:37     ` Robert Pendell
  2013-02-27 15:44       ` Eliot Moss
  2013-02-27 15:50       ` Kevin Layer
  2013-02-27 16:08     ` Eliot Moss
  1 sibling, 2 replies; 26+ messages in thread
From: Robert Pendell @ 2013-02-27 15:37 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27  2:32 ` Arthur Tu
@ 2013-02-27  3:21   ` Kevin Layer
  2013-02-27 15:37     ` Robert Pendell
  2013-02-27 16:08     ` Eliot Moss
  0 siblings, 2 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27  3:21 UTC (permalink / raw)
  To: cygwin

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.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: startxwin started bash does not read .bashrc or .bash_profile
  2013-02-27  0:08 Kevin Layer
@ 2013-02-27  2:32 ` Arthur Tu
  2013-02-27  3:21   ` Kevin Layer
  2013-02-27 17:55 ` Jon TURNEY
  1 sibling, 1 reply; 26+ messages in thread
From: Arthur Tu @ 2013-02-27  2:32 UTC (permalink / raw)
  To: cygwin

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?


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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* startxwin started bash does not read .bashrc or .bash_profile
@ 2013-02-27  0:08 Kevin Layer
  2013-02-27  2:32 ` Arthur Tu
  2013-02-27 17:55 ` Jon TURNEY
  0 siblings, 2 replies; 26+ messages in thread
From: Kevin Layer @ 2013-02-27  0:08 UTC (permalink / raw)
  To: cygwin

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.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-03-01 17:35 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-27 22:45 startxwin started bash does not read .bashrc or .bash_profile Kevin Layer
  -- strict thread matches above, loose matches on Subject: below --
2013-02-27  0:08 Kevin Layer
2013-02-27  2:32 ` Arthur Tu
2013-02-27  3:21   ` Kevin Layer
2013-02-27 15:37     ` Robert Pendell
2013-02-27 15:44       ` Eliot Moss
2013-02-27 15:50       ` Kevin Layer
2013-02-27 16:08     ` Eliot Moss
2013-02-27 16:20       ` Kevin Layer
2013-02-27 17:11         ` K Stahl
2013-02-27 18:07           ` Kevin Layer
2013-02-27 22:19           ` Kevin Layer
2013-02-27 23:14           ` Kevin Layer
2013-02-27 17:55 ` Jon TURNEY
2013-02-27 17:59   ` Kevin Layer
2013-02-27 19:50     ` Andrey Repin
2013-02-27 20:09       ` Christopher Faylor
2013-02-27 20:15       ` Kevin Layer
2013-02-27 21:17         ` Earnie Boyd
2013-02-27 22:16           ` Kevin Layer
2013-02-28 13:24             ` Earnie Boyd
2013-02-28 14:28               ` Kevin Layer
2013-03-01 14:11                 ` Earnie Boyd
2013-03-01 15:49                   ` Kevin Layer
2013-03-01 16:13                     ` Chris J. Breisch
2013-03-01 17:35                       ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).