commit: 8b953a8e6379bfcba06cf1b15414a3a1d55074f1
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jul 27 20:07:23 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 08:14:20 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8b953a8e
phase-helpers.sh: refrain from meddling with nullglob
Both _eapply_patch() and eapply_user() set nullglob before looking for
patches. However, both also iterate over * before proceeding to compare
the subject variable to the patterns *.diff and *.patch. Given that,
it's not really worth the effort of enabling nullglob. In the case that
the glob expands as itself, it can't possibly match either of those
patterns. In turn, there is no justification for incurring the expense
of a subshell to grab the output of shopt -p.
While at it, use a raw extglob to compare against the aforementioned
patterns, serving as a micro-optimisation. Note that, since bash-4.1,
this is always legal syntax, irrespective of whether the applicable
shopt is enabled or not.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/phase-helpers.sh | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index dc1c0b3129..da90cf3a5c 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -1046,15 +1046,12 @@ if ___eapi_has_eapply; then
if [[ -d ${f} ]]; then
_eapply_get_files() {
local LC_ALL=POSIX
- local prev_shopt=$(shopt -p nullglob)
- shopt -s nullglob
local f
for f in "${1}"/*; do
- if [[ ${f} == *.diff || ${f} ==
*.patch ]]; then
+ if [[ ${f} == *.@(diff|patch)
]]; then
files+=( "${f}" )
fi
done
- ${prev_shopt}
}
local files=()
@@ -1099,8 +1096,6 @@ if ___eapi_has_eapply_user; then
local applied d f
local -A _eapply_user_patches
- local prev_shopt=$(shopt -p nullglob)
- shopt -s nullglob
# Patches from all matched directories are combined into a
# sorted (POSIX order) list of the patch basenames. Patches
@@ -1117,7 +1112,7 @@ if ___eapi_has_eapply_user; then
# all of the above may be optionally followed by a slot
for d in
"${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},}; do
for f in "${d}"/*; do
- if [[ ( ${f} == *.diff || ${f} == *.patch ) &&
+ if [[ ${f} == *.@(diff|patch) &&
-z ${_eapply_user_patches[${f##*/}]}
]]; then
_eapply_user_patches[${f##*/}]=${f}
fi
@@ -1140,8 +1135,6 @@ if ___eapi_has_eapply_user; then
LC_ALL=C sort -z)
fi
- ${prev_shopt}
-
if [[ -n ${applied} ]]; then
einfo "User patches applied."
einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column
< ${columns} - 3; column++)); do echo -n =; done)${PORTAGE_COLOR_NORMAL}"