commit: caf3e5dcb3960e2eb80a90ee5b91ddafb0220914
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Aug 24 23:11:29 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 25 09:51:32 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=caf3e5dc
save-ebuild-env.sh: use MAPFILE to hold identifiers instead of REPLY
Presently, the __save_ebuild_env() function purposes the 'REPLY'
variable as an array for temporarily holding lists of identifiers that
are to be unset. The 'REPLY' variable was chosen on the basis that it
its value is normally controlled by the read builtin. That is, by using
it, the probability of a namespace conflict is reduced.
However, 'REPLY' is not normally an array variable. While this
observation is of no significance in and as of itself, some might find
it strange to see that particular variable be used as an array. In view
of this, purpose 'MAPFILE' as an array instead. For those that don't
know, that is the variable populated by the mapfile/readarray builtin,
provided that no name is specified.
See-also: fd01f441afa9053cdbbf47252255d19693d299c9
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/save-ebuild-env.sh | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index c1e6858e64..f195729232 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -11,14 +11,14 @@
# or removal of the packages, and can therefore be safely excluded.
#
__save_ebuild_env() (
- # REPLY is purposed as an array that undergoes two phases of assembly.
+ # MAPFILE is purposed as an array that undergoes two phases of assembly.
# The first entails gathering the names of variables that are to be
# unset. The second entails gathering the names of functions that are
- # to be unset. The REPLY variable is eventually unset in its own right.
- REPLY=()
+ # to be unset.
+ MAPFILE=()
if has --exclude-init-phases "$@"; then
- REPLY+=(
+ MAPFILE+=(
# Discard stale GNU Make POSIX Jobserver flags.
MAKEFLAGS
@@ -38,12 +38,12 @@ __save_ebuild_env() (
if [[ ${PYTHONPATH} == *:* ]] ; then
export PYTHONPATH=${PYTHONPATH#*:}
else
- REPLY+=( PYTHONPATH )
+ MAPFILE+=( PYTHONPATH )
fi
fi
fi
- REPLY+=(
+ MAPFILE+=(
# Variables that can influence the behaviour of GNU coreutils.
BLOCK_SIZE
COLORTERM
@@ -167,9 +167,9 @@ __save_ebuild_env() (
)
# Unset the collected variables before moving on to functions.
- unset -v "${REPLY[@]}"
+ unset -v "${MAPFILE[@]}"
- REPLY=(
+ MAPFILE=(
EXPORT_FUNCTIONS
KV_major
KV_micro
@@ -285,26 +285,26 @@ __save_ebuild_env() (
${QA_INTERCEPTORS}
)
- for _ in \
+ for REPLY in \
pkg_{config,info,nofetch,postinst,preinst,pretend,postrm,prerm,setup} \
src_{configure,compile,install,prepare,test,unpack}
do
- REPLY+=( default_"${_}" __eapi{0,1,2,4,6,8}_"${_}" )
+ MAPFILE+=( default_"${REPLY}" __eapi{0,1,2,4,6,8}_"${REPLY}" )
done
- ___eapi_has_version_functions && REPLY+=( ver_test ver_cut ver_rs )
- ___eapi_has_einstalldocs && REPLY+=( einstalldocs )
- ___eapi_has_eapply_user && REPLY+=( __readdir eapply_user )
- ___eapi_has_get_libdir && REPLY+=( get_libdir )
- ___eapi_has_in_iuse && REPLY+=( in_iuse )
- ___eapi_has_eapply && REPLY+=( __eapply_patch eapply patch )
- ___eapi_has_usex && REPLY+=( usex )
- ___eapi_has_pipestatus && REPLY+=( pipestatus )
- ___eapi_has_ver_replacing && REPLY+=( ver_replacing )
- ___eapi_has_edo && REPLY+=( edo )
+ ___eapi_has_version_functions && MAPFILE+=( ver_test ver_cut ver_rs )
+ ___eapi_has_einstalldocs && MAPFILE+=( einstalldocs )
+ ___eapi_has_eapply_user && MAPFILE+=( __readdir eapply_user )
+ ___eapi_has_get_libdir && MAPFILE+=( get_libdir )
+ ___eapi_has_in_iuse && MAPFILE+=( in_iuse )
+ ___eapi_has_eapply && MAPFILE+=( __eapply_patch eapply patch )
+ ___eapi_has_usex && MAPFILE+=( usex )
+ ___eapi_has_pipestatus && MAPFILE+=( pipestatus )
+ ___eapi_has_ver_replacing && MAPFILE+=( ver_replacing )
+ ___eapi_has_edo && MAPFILE+=( edo )
# Destroy the collected functions.
- unset -f "${REPLY[@]}"
+ unset -f "${MAPFILE[@]}"
# Clear out the triple underscore namespace as it is reserved by the PM.
while IFS=' ' read -r _ _ REPLY; do
@@ -312,7 +312,7 @@ __save_ebuild_env() (
unset -f "${REPLY}"
fi
done < <(declare -F)
- unset -v REPLY "${!___@}"
+ unset -v MAPFILE REPLY "${!___@}"
declare -p
declare -fp