commit: 2157e76866dc90a3946b912caa34a511c6b17e60
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jul 28 07:30:17 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 25 09:51:34 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2157e768
Don't strip SHELL while saving and restoring environments
The 'SHELL' variable is set by whatever is responsible for handling the
procedure of logging in, be it login(1), sshd(8) or a display manager.
Its value is taken from the user's password entry and specifies their
choice of login shell. Additionally, bash(1) sets the variable, albeit
only in the (irregular) case that it is missing in its environment at
the time of execution. Ideally, it should not be set by other programs,
nor should any other meaning or purpose be ascribed to it.
Unfortunately, some packages define and export the 'SHELL' variable
during the src_configure phase. Among them are the following:
- app-admin/entr
- dev-lang/spidermonkey
- mail-client/thunderbird
- www-client/firefox
- www-client/seamonkey
While there is a reason for their doing so, it is not immediately clear
as to whether there is an actual need for the variable to persist
between ebuild phases. That is, it may be that the variable only needs
to be present in the environment of the configure program. Still, until
such time as this can be established with absolute certainty, it would
be prudent to avoid the risk of incurring a regression.
For now, refrain from filtering out the 'SHELL' variable in both the
__save_ebuild_env() function of the "save-ebuild-env.sh" unit, and the
__filter_readonly_variables() function of the "phase-functions.sh" unit.
See-also: 8a607ed23beb4995627f9c4e2c7580469ace56bb
See-also: 1df2556c3aeebc64f64c5e6a2f92d9f4a68eb9da
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/phase-functions.sh | 5 +++--
bin/save-ebuild-env.sh | 1 -
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 5c9f488a90..98b2784c96 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -50,7 +50,7 @@ portage_mutable_filtered_vars=( AA HOSTNAME )
# Read an environment from stdin and echo to stdout while filtering variables
# with names that are known to cause interference:
#
-# * all variables that can be set by or that affect bash (except EMACS &
PATH)
+# * variables that can be set by or that affect bash (with several
exceptions)
# * some specific variables that affect portage or sandbox behavior
# * variable names that begin with a digit or that contain any
# non-alphanumeric characters that are not be supported by bash
@@ -94,10 +94,11 @@ __filter_readonly_variables() {
mapfile -t bash_vars < <(
# Like compgen -A variable but doesn't require readline support.
env -i -- "${BASH}" -c "printf %s\\\n $(printf '${!%s*} '
{A..Z} {a..z} _)" \
- | grep -vx PATH
+ | grep -vx -e PATH -e SHELL
)
# Incorporate other variables that are known to either be set by or be
# able to influence bash. This list was last updated for bash-5.3.
+ # EMACS is omitted, so as not to break the "elisp-common" eclass.
bash_vars+=(
BASH_LOADABLES_PATH BASH_XTRACEFD BASH_REMATCH BASH_TRAPSIG
BASH_COMPAT BASH_ENV COMP_CWORD COMP_POINT COMP_WORDS CHILD_MAX
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 77d3852d48..b520a94858 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -56,7 +56,6 @@ __save_ebuild_env() (
POSIXLY_CORRECT
PWD
QUOTING_STYLE
- SHELL
TABSIZE
TERM
TIME_STYLE