[Bug 278184] shells/bash: /etc/profile is not loaded
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 05 Apr 2024 09:33:52 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278184
Bug ID: 278184
Summary: shells/bash: /etc/profile is not loaded
Product: Ports & Packages
Version: Latest
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: Individual Port(s)
Assignee: ehaupt@FreeBSD.org
Reporter: thomas.dreibholz@gmail.com
Flags: maintainer-feedback?(ehaupt@FreeBSD.org)
Assignee: ehaupt@FreeBSD.org
Bash does not load /etc/profile since some time. Instead, it expects
${LOCALBASE}/etc/profile. This is possibly intended behaviour now, but may come
unexpected to a user using a Bash shell on a system with system-wide profile
settings.
Just making a symlink /etc/profile -> /usr/local/etc/profile (as suggested by
https://forums.freebsd.org/threads/what-happened-to-etc-profile.78406/) also
does not properly lead to the expected behaviour, since this leads to loading
/etc/profile twice: The issue is that /etc/profile (at least in 14.0-RELEASE)
is trying to avoid this recursion by checking whether it tries to load itself.
But since "/usr/local/etc/profile" is not equal to "/etc/profile", this check
fails. If the profile settings are just setting variables, this is probably not
an issue (just a bit of wasted time). However, if making output like a login
banner (e.g. using the "td-system-tools" package, which installs
/usr/local/etc/profile.d/system-info.sh for this purpose), the output is made
twice.
A work around is to have a script /usr/local/etc/profile, which checks whether
it is called by /etc/profile (/etc/profile sets a variable _loaded; if it is
set, then just do not try to load /etc/profile again):
if [ "${_loaded}" = "" ] ; then
if [ -e /etc/profile ] ; then
. /etc/profile
fi
fi
May be such a /usr/local/etc/profile script should be installed by the Bash
package as default, to get the probably expected user behaviour of getting the
system-wide profile settings with Bash shell as well?
--
You are receiving this mail because:
You are the assignee for the bug.