bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash login shell detection broken using default compile options


From: Greg Wooledge
Subject: Re: bash login shell detection broken using default compile options
Date: Thu, 16 Mar 2023 13:18:26 -0400

On Thu, Mar 16, 2023 at 05:21:23PM +0100, Tycho Kirchner wrote:
> Hi,
> when compiling bash with a plain
> 
> mkdir build; cd build; ../configure && make
> 
> the login shell detection (leading dash: -bash) is apparently broken - at 
> least, ~/.bashrc is not sourced.

What you're referring to is an optional compile-time feature, which
is not enabled in the vanilla bash source code.

> This happens in all tested versions, from 4.4 until the latest release 5.2.15.
> Interestingly, using distribution provided binaries, everything is fine 
> (tested on Debian Bullseye, Debian testing and OpenSuse Leap).

Those particular Linux vendors must have chosen to enable it.

/* Define this to make non-interactive shells begun with argv[0][0] == '-'
   run the startup files when not in posix mode. */
/* #define NON_INTERACTIVE_LOGIN_SHELLS */

If you want to turn this on, it's in config-top.h.

> echo hi from bashrc >&2
> 
> to the beginning of your ~/.bashrc.

For the record, ~/.bashrc is not a file that's read (directly) by bash
when invoked in this mode.  You must be sourcing it from your ~/.profile
or ~/.bash_{profile,login} file.

Also for the record, you can skip Python in your reproducer.  Bash'e
exec -a can do the same thing:

unicorn:~$ (exec -a -bash /bin/bash nosuchscript)
hi from .profile
-bash: nosuchscript: No such file or directory
unicorn:~$ (exec -a -bash /usr/local/bin/bash-5.2 nosuchscript)
-bash: nosuchscript: No such file or directory

(I'm on Debian too, so I can confirm that Debian has enabled this
NON_INTERACTIVE_LOGIN_SHELLS feature in its /bin/bash.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]