unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29337: Bash reads system-wide bashrc unconditionally.
@ 2017-11-17 12:16 Roel Janssen
  2017-11-17 21:04 ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Roel Janssen @ 2017-11-17 12:16 UTC (permalink / raw)
  To: 29337

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

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-11-17 12:16 bug#29337: Bash reads system-wide bashrc unconditionally Roel Janssen
@ 2017-11-17 21:04 ` Ludovic Courtès
  2017-11-20 21:48   ` Roel Janssen
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2017-11-17 21:04 UTC (permalink / raw)
  To: Roel Janssen; +Cc: 29337

Hi,

Roel Janssen <roel@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’.

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-11-17 21:04 ` Ludovic Courtès
@ 2017-11-20 21:48   ` Roel Janssen
  2017-11-21  8:50     ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Roel Janssen @ 2017-11-20 21:48 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 29337-done


Ludovic Courtès writes:

> Hi,
>
> Roel Janssen <roel@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

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-11-20 21:48   ` Roel Janssen
@ 2017-11-21  8:50     ` Ludovic Courtès
  2017-11-24 15:46       ` Roel Janssen
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2017-11-21  8:50 UTC (permalink / raw)
  To: Roel Janssen; +Cc: 29337-done

Heya,

Roel Janssen <roel@gnu.org> skribis:

> Roel Janssen <roel@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’.

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-11-21  8:50     ` Ludovic Courtès
@ 2017-11-24 15:46       ` Roel Janssen
  2017-11-24 20:51         ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Roel Janssen @ 2017-11-24 15:46 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 29337-done


Ludovic Courtès writes:

> Heya,
>
> Roel Janssen <roel@gnu.org> skribis:
>
>> Roel Janssen <roel@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

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-11-24 15:46       ` Roel Janssen
@ 2017-11-24 20:51         ` Ludovic Courtès
  2017-12-11 11:35           ` Roel Janssen
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2017-11-24 20:51 UTC (permalink / raw)
  To: Roel Janssen; +Cc: 29337-done

Roel Janssen <roel@gnu.org> skribis:

> Ludovic Courtès writes:
>
>> Heya,
>>
>> Roel Janssen <roel@gnu.org> skribis:
>>
>>> Roel Janssen <roel@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’.

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-11-24 20:51         ` Ludovic Courtès
@ 2017-12-11 11:35           ` Roel Janssen
  2017-12-11 13:19             ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Roel Janssen @ 2017-12-11 11:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 29337-done


Ludovic Courtès writes:

> Roel Janssen <roel@gnu.org> skribis:
>
>> Ludovic Courtès writes:
>>
>>> Heya,
>>>
>>> Roel Janssen <roel@gnu.org> skribis:
>>>
>>>> Roel Janssen <roel@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

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-12-11 11:35           ` Roel Janssen
@ 2017-12-11 13:19             ` Ludovic Courtès
  2017-12-11 15:31               ` Roel Janssen
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2017-12-11 13:19 UTC (permalink / raw)
  To: Roel Janssen; +Cc: 29337-done

Roel Janssen <roel@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’.

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

* bug#29337: Bash reads system-wide bashrc unconditionally.
  2017-12-11 13:19             ` Ludovic Courtès
@ 2017-12-11 15:31               ` Roel Janssen
  0 siblings, 0 replies; 9+ messages in thread
From: Roel Janssen @ 2017-12-11 15:31 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 29337-done


Ludovic Courtès writes:

> Roel Janssen <roel@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

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

end of thread, other threads:[~2017-12-11 15:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 12:16 bug#29337: Bash reads system-wide bashrc unconditionally Roel Janssen
2017-11-17 21:04 ` Ludovic Courtès
2017-11-20 21:48   ` Roel Janssen
2017-11-21  8:50     ` Ludovic Courtès
2017-11-24 15:46       ` Roel Janssen
2017-11-24 20:51         ` Ludovic Courtès
2017-12-11 11:35           ` Roel Janssen
2017-12-11 13:19             ` Ludovic Courtès
2017-12-11 15:31               ` Roel Janssen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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