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.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Roel Janssen <roel <at> gnu.org>
Subject: bug#29337: closed (Re: bug#29337: Bash reads system-wide bashrc
 unconditionally.)
Date: Mon, 20 Nov 2017 21:49:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#29337: Bash reads system-wide bashrc unconditionally.

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 29337 <at> debbugs.gnu.org.

-- 
29337: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29337
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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

[Message part 3 (message/rfc822, inline)]
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



This bug report was last modified 7 years and 166 days ago.

Previous Next


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