FS#50567 - [bash] Define NON_INTERACTIVE_LOGIN_SHELLS

Attached to Project: Arch Linux
Opened by Marcos Mello (marcosfrm) - Monday, 29 August 2016, 13:39 GMT
Last edited by Jan Alexander Steffens (heftig) - Tuesday, 14 February 2017, 13:36 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Bartłomiej Piotrowski (Barthalion)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I find pretty confusing when I log in text mode I get all my custom settings from /etc/profile.d files and when I open GNOME Terminal I do not.

Compiling bash with NON_INTERACTIVE_LOGIN_SHELLS defined appears to fix this behaviour[1]. However I do not have a strong background to know if the change can cause breakage in other components.

[1] Fedora, Debian, openSUSE, define it.
http://pkgs.fedoraproject.org/cgit/rpms/bash.git/tree/bash-2.03-profile.patch
https://sources.debian.net/patches/bash/4.3-15/deb-bash-config.diff/
https://build.opensuse.org/package/view_file/openSUSE:Factory/bash/bash-4.3.dif?expand=1
This task depends upon

Closed by  Jan Alexander Steffens (heftig)
Tuesday, 14 February 2017, 13:36 GMT
Reason for closing:  Fixed
Additional comments about closing:  bash 4.4.012-2
Comment by Marcos Mello (marcosfrm) - Monday, 29 August 2016, 16:00 GMT
Sorry, this should go to Project: Arch Linux, Packages: Core.
Comment by Marcos Mello (marcosfrm) - Tuesday, 30 August 2016, 11:44 GMT
Nevermind, NON_INTERACTIVE_LOGIN_SHELLS does not help in this case, GNOME Terminal runs bash as an interactive non-login shell.

It works in Fedora because ~/.bashrc sources /etc/bashrc, which then sources /etc/profile.d files if bash runs as a non-login shell.
Comment by Marcos Mello (marcosfrm) - Tuesday, 30 August 2016, 13:13 GMT
I borrowed from Fedora

https://git.fedorahosted.org/cgit/setup.git/tree/bashrc

this snippet

if ! shopt -q login_shell ; then
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
fi

and put it at the end of Arch's /etc/bash.bashrc. Works so far.
Comment by userwithuid (userwithuid) - Friday, 02 September 2016, 22:06 GMT
I'm pretty sure sourcing the at-login stuff (profile) should not happen every time you open another bash, that's what bashrc is for.

Aside from what should be, in practice arch packages seem to append $PATH in profile.d/*.sh unconditionally, so you would get n duplicate entries for the subshell at depth n.

What custom settings do you have in profile? Exported environment variables will propagate to subshells (including gnome terminal), other stuff could be moved to bashrc.
Comment by Marcos Mello (marcosfrm) - Wednesday, 16 November 2016, 09:57 GMT
Sorry for the late answer.

Just some aliases and proxy settings. I migrated them to bashrc.

For GNOME Terminal it is still an issue: https://bugs.archlinux.org/task/39684

Please close this bug. Thanks.
Comment by Jan Alexander Steffens (heftig) - Tuesday, 07 February 2017, 22:06 GMT
This feature (non-interactive bash launched as "-bash" sources /etc/profile) is now needed by gnome-session to ensure the profile is read through a login shell.
https://bugzilla.gnome.org/show_bug.cgi?id=736660#c110

It's enabled in both Debian and Fedora (both via a patch, not the environment).

Other shells (at least dash, zsh, fish, busybox ash) behave this way already, just our bash does not.

Loading...