diff mbox series

[bug#42752,core-updates] gnu: bash: Make completions work in non-login shells.

Message ID 20200807221439.729-1-kuba@kadziolka.net
State New
Headers show
Series [bug#42752,core-updates] gnu: bash: Make completions work in non-login shells. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Maja Kądziołka Aug. 7, 2020, 10:14 p.m. UTC
Currently, /etc/bashrc is only loaded by /etc/profile. Because the
former is responsible for setting up command-specific completions, they
currently only work in login shells. This patch configures bash to load
/etc/bashrc in interactive non-login shells, as by default no
system-wide configuration is loaded.

* gnu/packages/bash.scm (bash): Set SYS_BASHRC to /etc/bashrc.
---
 gnu/packages/bash.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Mathieu Othacehe Aug. 10, 2020, 9:25 a.m. UTC | #1
Hey Jakub,

> Currently, /etc/bashrc is only loaded by /etc/profile. Because the
> former is responsible for setting up command-specific completions, they
> currently only work in login shells. This patch configures bash to load
> /etc/bashrc in interactive non-login shells, as by default no
> system-wide configuration is loaded.

/etc/bashrc is also loaded by ~/.bashrc in "default-skeletons". So your
patch would cover the case of an interactive, non-login shell run by a
logged in user without the default ~/.bashrc file, right?

Thanks,

Mathieu
Maja Kądziołka Aug. 10, 2020, 2:41 p.m. UTC | #2
On Mon, Aug 10, 2020 at 11:25:12AM +0200, Mathieu Othacehe wrote:
> 
> Hey Jakub,
> 
> > Currently, /etc/bashrc is only loaded by /etc/profile. Because the
> > former is responsible for setting up command-specific completions, they
> > currently only work in login shells. This patch configures bash to load
> > /etc/bashrc in interactive non-login shells, as by default no
> > system-wide configuration is loaded.
> 
> /etc/bashrc is also loaded by ~/.bashrc in "default-skeletons". So your
> patch would cover the case of an interactive, non-login shell run by a
> logged in user without the default ~/.bashrc file, right?

Oh! It seems I overwrote it with my own .bashrc when I migrated my
dotfiles. I still think this patch is a good idea - I think we should
make /etc/skel/.bashrc contain only nice-to-have defaults, such as
changing the prompt based on $GUIX_ENVIRONMENT, and move the essential
things to /etc/bashrc. That way, overwriting the .bashrc won't break
anything important.

I guess I should follow this patch up with an adjustment to
/etc/skel/.bashrc, removing the 'source /etc/bashrc' line?

Regards,
Jakub Kądziołka
Mathieu Othacehe Aug. 11, 2020, 8:44 a.m. UTC | #3
Hello,

> Oh! It seems I overwrote it with my own .bashrc when I migrated my
> dotfiles. I still think this patch is a good idea - I think we should
> make /etc/skel/.bashrc contain only nice-to-have defaults, such as
> changing the prompt based on $GUIX_ENVIRONMENT, and move the essential
> things to /etc/bashrc. That way, overwriting the .bashrc won't break
> anything important.
>
> I guess I should follow this patch up with an adjustment to
> /etc/skel/.bashrc, removing the 'source /etc/bashrc' line?

That would make sense. Maybe you could replace the sourcing by a comment
explaining how bash behaviour is altered to source /etc/bashrc for
interactive, non-login shell.

Thanks,

Mathieu
Maxim Cournoyer Oct. 21, 2023, 7:24 p.m. UTC | #4
Hi,

Mathieu Othacehe <othacehe@gnu.org> writes:

> Hello,
>
>> Oh! It seems I overwrote it with my own .bashrc when I migrated my
>> dotfiles. I still think this patch is a good idea - I think we should
>> make /etc/skel/.bashrc contain only nice-to-have defaults, such as
>> changing the prompt based on $GUIX_ENVIRONMENT, and move the essential
>> things to /etc/bashrc. That way, overwriting the .bashrc won't break
>> anything important.
>>
>> I guess I should follow this patch up with an adjustment to
>> /etc/skel/.bashrc, removing the 'source /etc/bashrc' line?
>
> That would make sense. Maybe you could replace the sourcing by a comment
> explaining how bash behaviour is altered to source /etc/bashrc for
> interactive, non-login shell.

I somewhat weary of the undefined behavior this could have on foreign
distributions?

I'll close this, but feel free to continue discussing it here.
diff mbox series

Patch

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 47ca625d9a..9784e2ccc1 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -108,7 +108,8 @@  number/base32-hash tuples, directly usable in the 'patch-series' form."
   (let* ((cppflags (string-join '("-DDEFAULT_PATH_VALUE='\"/no-such-path\"'"
                                   "-DSTANDARD_UTILS_PATH='\"/no-such-path\"'"
                                   "-DNON_INTERACTIVE_LOGIN_SHELLS"
-                                  "-DSSH_SOURCE_BASHRC")
+                                  "-DSSH_SOURCE_BASHRC"
+                                  "-DSYS_BASHRC='\"/etc/bashrc\"'")
                                 " "))
          (configure-flags
           ``("--with-installed-readline"