GNU bug report logs - #29337
Bash reads system-wide bashrc unconditionally.

Previous Next

Package: guix;

Reported by: Roel Janssen <roel <at> gnu.org>

Date: Fri, 17 Nov 2017 12:17:02 UTC

Severity: normal

Done: Roel Janssen <roel <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29337 in the body.
You can then email your comments to 29337 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Fri, 17 Nov 2017 12:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Roel Janssen <roel <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Fri, 17 Nov 2017 12:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Roel Janssen <roel <at> gnu.org>
To: bug-guix <at> gnu.org
Subject: Bash reads system-wide bashrc unconditionally.
Date: Fri, 17 Nov 2017 13:16:13 +0100
Dear Guix,

This is more of an issue for GuixSD.
Our 'bash' package seems to behave differently from other distributions
(like CentOS 7), and it behaves differently from the way described in its
manual page.

I added the following line to /etc/bashrc:
echo "Hello, world"

Here's the command to reproduce the problem:
$ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
Hello, world
Goodbye, world


From the manpage:
...
       -i        If the -i option is present, the shell is interactive.
...
       --init-file file
       --rcfile file
              Execute commands from file instead of the standard personal initialization file ~/.bashrc if the shell is interactive (see INVOCATION below).
...


So, what should happen, is that it ignores the system-wide initialization
file (and the user's initialization file).

On CentOS 7, the following happens (yes, I added the echo-statement to
/etc/bashrc on CentOS as well):
$ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
Goodbye, world

On GuixSD:
$ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
Hello, world
Goodbye, world

Where does this difference come from?  And could we make its behavior
similar to CentOS 7, and more importantly, to the description in the
manpage?

Kind regards,
Roel Janssen




Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Fri, 17 Nov 2017 21:05:01 GMT) Full text and rfc822 format available.

Message #8 received at 29337 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Roel Janssen <roel <at> gnu.org>
Cc: 29337 <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Fri, 17 Nov 2017 22:04:52 +0100
Hi,

Roel Janssen <roel <at> gnu.org> skribis:

> On CentOS 7, the following happens (yes, I added the echo-statement to
> /etc/bashrc on CentOS as well):
> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
> Goodbye, world
>
> On GuixSD:
> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
> Hello, world
> Goodbye, world
>
> Where does this difference come from?  And could we make its behavior
> similar to CentOS 7, and more importantly, to the description in the
> manpage?

By default GuixSD’s /etc/profile (sourced by interactive shells) does
this:

--8<---------------cut here---------------start------------->8---
if [ -n "$BASH_VERSION" -a -f /etc/bashrc ]
then
  # Load Bash-specific initialization code.
  . /etc/bashrc
fi
--8<---------------cut here---------------end--------------->8---

It comes from commit 1d167b6e3779bcc1666b5c7d5ee802170c7023b6, which was
about loading the Bash completion code.

Looking at the manual (info "(bash) Bash Startup Files"), I think that
/etc/bashrc is ignored by default.  Thus it’s up to users/distros to
decide what to do with it, IIUC.

Thoughts?

Ludo’.




Reply sent to Roel Janssen <roel <at> gnu.org>:
You have taken responsibility. (Mon, 20 Nov 2017 21:49:02 GMT) Full text and rfc822 format available.

Notification sent to Roel Janssen <roel <at> gnu.org>:
bug acknowledged by developer. (Mon, 20 Nov 2017 21:49:02 GMT) Full text and rfc822 format available.

Message #13 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: Roel Janssen <roel <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Mon, 20 Nov 2017 22:48:37 +0100
Ludovic Courtès writes:

> Hi,
>
> Roel Janssen <roel <at> gnu.org> skribis:
>
>> On CentOS 7, the following happens (yes, I added the echo-statement to
>> /etc/bashrc on CentOS as well):
>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>> Goodbye, world
>>
>> On GuixSD:
>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>> Hello, world
>> Goodbye, world
>>
>> Where does this difference come from?  And could we make its behavior
>> similar to CentOS 7, and more importantly, to the description in the
>> manpage?
>
> By default GuixSD’s /etc/profile (sourced by interactive shells) does
> this:
>
> --8<---------------cut here---------------start------------->8---
> if [ -n "$BASH_VERSION" -a -f /etc/bashrc ]
> then
>   # Load Bash-specific initialization code.
>   . /etc/bashrc
> fi
> --8<---------------cut here---------------end--------------->8---
>
> It comes from commit 1d167b6e3779bcc1666b5c7d5ee802170c7023b6, which was
> about loading the Bash completion code.
>
> Looking at the manual (info "(bash) Bash Startup Files"), I think that
> /etc/bashrc is ignored by default.  Thus it’s up to users/distros to
> decide what to do with it, IIUC.
>
> Thoughts?

Thanks for your reply, Ludo’! 

Well it seems that it isn't ignored when it ought to be ignored -> when
specifying --init-file.  This is a difference between how Bash works on
CentOS 7, and how Bash works on Guix(SD).  I can't find a
user-configurable option to make it work the same as on CentOS 7.

I think I can also achieve my goal by invoking it as "sh", prepending
"env - ENV=/path/to/etc/profile", and setting some environment variables
like HOME and PS1.  So I'll go that route, leaving Guix's Bash
alone. :-)

Kind regards,
Roel Janssen




Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Tue, 21 Nov 2017 08:51:02 GMT) Full text and rfc822 format available.

Message #16 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Roel Janssen <roel <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Tue, 21 Nov 2017 09:50:01 +0100
Heya,

Roel Janssen <roel <at> gnu.org> skribis:

> Roel Janssen <roel <at> gnu.org> skribis:
>
>>> On CentOS 7, the following happens (yes, I added the echo-statement to
>>> /etc/bashrc on CentOS as well):
>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>> Goodbye, world
>>>
>>> On GuixSD:
>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>> Hello, world
>>> Goodbye, world

> Well it seems that it isn't ignored when it ought to be ignored -> when
> specifying --init-file.  This is a difference between how Bash works on
> CentOS 7, and how Bash works on Guix(SD).  I can't find a
> user-configurable option to make it work the same as on CentOS 7.

Now, we’re compiling Bash with "-DSYS_BASHRC='\"/etc/bashrc\"'".  I
wonder if removing that flag solves the --init-file case.

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Fri, 24 Nov 2017 15:48:02 GMT) Full text and rfc822 format available.

Message #19 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: Roel Janssen <roel <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Fri, 24 Nov 2017 16:46:43 +0100
Ludovic Courtès writes:

> Heya,
>
> Roel Janssen <roel <at> gnu.org> skribis:
>
>> Roel Janssen <roel <at> gnu.org> skribis:
>>
>>>> On CentOS 7, the following happens (yes, I added the echo-statement to
>>>> /etc/bashrc on CentOS as well):
>>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>>> Goodbye, world
>>>>
>>>> On GuixSD:
>>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>>> Hello, world
>>>> Goodbye, world
>
>> Well it seems that it isn't ignored when it ought to be ignored -> when
>> specifying --init-file.  This is a difference between how Bash works on
>> CentOS 7, and how Bash works on Guix(SD).  I can't find a
>> user-configurable option to make it work the same as on CentOS 7.
>
> Now, we’re compiling Bash with "-DSYS_BASHRC='\"/etc/bashrc\"'".  I
> wonder if removing that flag solves the --init-file case.

It does.  So, I have a custom bash package for my specific use-case.
I'm not sure how it affects other functionality, but I would like it if
we could make this change upstream at some point.

Kind regards,
Roel Janssen






Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Fri, 24 Nov 2017 20:52:02 GMT) Full text and rfc822 format available.

Message #22 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Roel Janssen <roel <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Fri, 24 Nov 2017 21:51:30 +0100
Roel Janssen <roel <at> gnu.org> skribis:

> Ludovic Courtès writes:
>
>> Heya,
>>
>> Roel Janssen <roel <at> gnu.org> skribis:
>>
>>> Roel Janssen <roel <at> gnu.org> skribis:
>>>
>>>>> On CentOS 7, the following happens (yes, I added the echo-statement to
>>>>> /etc/bashrc on CentOS as well):
>>>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>>>> Goodbye, world
>>>>>
>>>>> On GuixSD:
>>>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>>>> Hello, world
>>>>> Goodbye, world
>>
>>> Well it seems that it isn't ignored when it ought to be ignored -> when
>>> specifying --init-file.  This is a difference between how Bash works on
>>> CentOS 7, and how Bash works on Guix(SD).  I can't find a
>>> user-configurable option to make it work the same as on CentOS 7.
>>
>> Now, we’re compiling Bash with "-DSYS_BASHRC='\"/etc/bashrc\"'".  I
>> wonder if removing that flag solves the --init-file case.
>
> It does.  So, I have a custom bash package for my specific use-case.
> I'm not sure how it affects other functionality, but I would like it if
> we could make this change upstream at some point.

Now’s the time to make that change in ‘core-updates’!

I don’t think it breaks things on GuixSD because /etc/profile sources
/etc/bashrc anyway.

Thoughts?

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Mon, 11 Dec 2017 11:36:02 GMT) Full text and rfc822 format available.

Message #25 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: Roel Janssen <roel <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Mon, 11 Dec 2017 12:35:22 +0100
Ludovic Courtès writes:

> Roel Janssen <roel <at> gnu.org> skribis:
>
>> Ludovic Courtès writes:
>>
>>> Heya,
>>>
>>> Roel Janssen <roel <at> gnu.org> skribis:
>>>
>>>> Roel Janssen <roel <at> gnu.org> skribis:
>>>>
>>>>>> On CentOS 7, the following happens (yes, I added the echo-statement to
>>>>>> /etc/bashrc on CentOS as well):
>>>>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>>>>> Goodbye, world
>>>>>>
>>>>>> On GuixSD:
>>>>>> $ env - bash --init-file <(echo "echo \"Goodbye, world\"") -i
>>>>>> Hello, world
>>>>>> Goodbye, world
>>>
>>>> Well it seems that it isn't ignored when it ought to be ignored -> when
>>>> specifying --init-file.  This is a difference between how Bash works on
>>>> CentOS 7, and how Bash works on Guix(SD).  I can't find a
>>>> user-configurable option to make it work the same as on CentOS 7.
>>>
>>> Now, we’re compiling Bash with "-DSYS_BASHRC='\"/etc/bashrc\"'".  I
>>> wonder if removing that flag solves the --init-file case.
>>
>> It does.  So, I have a custom bash package for my specific use-case.
>> I'm not sure how it affects other functionality, but I would like it if
>> we could make this change upstream at some point.
>
> Now’s the time to make that change in ‘core-updates’!
>
> I don’t think it breaks things on GuixSD because /etc/profile sources
> /etc/bashrc anyway.
>
> Thoughts?

I don't think it'll break things.  So I guess I'm too late for the
core-updates cycle.  Should I push this change to core-updates for the
next cycle?

Kind regards,
Roel Janssen





Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Mon, 11 Dec 2017 13:20:02 GMT) Full text and rfc822 format available.

Message #28 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Roel Janssen <roel <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Mon, 11 Dec 2017 14:19:46 +0100
Roel Janssen <roel <at> gnu.org> skribis:

> Ludovic Courtès writes:

[...]

>>>> Now, we’re compiling Bash with "-DSYS_BASHRC='\"/etc/bashrc\"'".  I
>>>> wonder if removing that flag solves the --init-file case.
>>>
>>> It does.  So, I have a custom bash package for my specific use-case.
>>> I'm not sure how it affects other functionality, but I would like it if
>>> we could make this change upstream at some point.
>>
>> Now’s the time to make that change in ‘core-updates’!
>>
>> I don’t think it breaks things on GuixSD because /etc/profile sources
>> /etc/bashrc anyway.
>>
>> Thoughts?
>
> I don't think it'll break things.  So I guess I'm too late for the
> core-updates cycle.

Yes.

> Should I push this change to core-updates for the next cycle?

You can create a ‘core-updates-next’ branch based on ‘core-updates’, or
wait until ‘core-updates’ has been merged (which could take at least two
weeks.)

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#29337; Package guix. (Mon, 11 Dec 2017 15:32:02 GMT) Full text and rfc822 format available.

Message #31 received at 29337-done <at> debbugs.gnu.org (full text, mbox):

From: Roel Janssen <roel <at> gnu.org>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 29337-done <at> debbugs.gnu.org
Subject: Re: bug#29337: Bash reads system-wide bashrc unconditionally.
Date: Mon, 11 Dec 2017 16:31:35 +0100
Ludovic Courtès writes:

> Roel Janssen <roel <at> gnu.org> skribis:
>
>> Ludovic Courtès writes:
>
> [...]
>
>>>>> Now, we’re compiling Bash with "-DSYS_BASHRC='\"/etc/bashrc\"'".  I
>>>>> wonder if removing that flag solves the --init-file case.
>>>>
>>>> It does.  So, I have a custom bash package for my specific use-case.
>>>> I'm not sure how it affects other functionality, but I would like it if
>>>> we could make this change upstream at some point.
>>>
>>> Now’s the time to make that change in ‘core-updates’!
>>>
>>> I don’t think it breaks things on GuixSD because /etc/profile sources
>>> /etc/bashrc anyway.
>>>
>>> Thoughts?
>>
>> I don't think it'll break things.  So I guess I'm too late for the
>> core-updates cycle.
>
> Yes.
>
>> Should I push this change to core-updates for the next cycle?
>
> You can create a ‘core-updates-next’ branch based on ‘core-updates’, or
> wait until ‘core-updates’ has been merged (which could take at least two
> weeks.)
>
> Ludo’.

I'll wait.  :-)

Thanks!

Kind regards,
Roel Janssen




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 09 Jan 2018 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 102 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.