commit: f38628e233815483f6edaac47e7c29a4ce6b3175
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jun 3 10:26:30 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 3 20:49:51 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f38628e2
bashrc-functions.sh: improve register_die_hook() and register_success_hook()
Rename the 'x' variable to 'hook'.
Refrain from performing word splitting and potential pathname expansion
upon the positional parameters, both at the point of iterating over them
and at the point of passing each to the has() function.
Refrain from pointlessly expanding the EBUILD_DEATH_HOOKS and
EBUILD_SUCCESS_HOOKS variables in the course of appending to them.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/bashrc-functions.sh | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/bin/bashrc-functions.sh b/bin/bashrc-functions.sh
index 93272df243..7859663fdb 100644
--- a/bin/bashrc-functions.sh
+++ b/bin/bashrc-functions.sh
@@ -3,18 +3,22 @@
# Distributed under the terms of the GNU General Public License v2
register_die_hook() {
- local x
- for x in $* ; do
- has ${x} ${EBUILD_DEATH_HOOKS} || \
- export EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} ${x}"
+ local hook
+
+ for hook; do
+ if ! has "${hook}" ${EBUILD_DEATH_HOOKS}; then
+ export EBUILD_DEATH_HOOKS+=" ${hook}"
+ fi
done
}
register_success_hook() {
- local x
- for x in $* ; do
- has ${x} ${EBUILD_SUCCESS_HOOKS} || \
- export EBUILD_SUCCESS_HOOKS="${EBUILD_SUCCESS_HOOKS}
${x}"
+ local hook
+
+ for hook; do
+ if ! has "${hook}" ${EBUILD_SUCCESS_HOOKS}; then
+ export EBUILD_SUCCESS_HOOKS+=" ${hook}"
+ fi
done
}