From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9C0621580E0 for ; Tue, 03 Jun 2025 20:50:12 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 7AC6A34310F for ; Tue, 03 Jun 2025 20:50:12 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 746281103C1; Tue, 03 Jun 2025 20:50:09 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 6E0031103C1 for ; Tue, 03 Jun 2025 20:50:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 208D2343099 for ; Tue, 03 Jun 2025 20:50:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 127B22817 for ; Tue, 03 Jun 2025 20:50:07 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1748983791.f38628e233815483f6edaac47e7c29a4ce6b3175.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/bashrc-functions.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: f38628e233815483f6edaac47e7c29a4ce6b3175 X-VCS-Branch: master Date: Tue, 03 Jun 2025 20:50:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2f814153-b6b7-4cde-93a5-734e20fd2351 X-Archives-Hash: d98aecb28c5dc875a9e050659ac33c5a commit: f38628e233815483f6edaac47e7c29a4ce6b3175 Author: Kerin Millar plushkava net> AuthorDate: Tue Jun 3 10:26:30 2025 +0000 Commit: Sam James gentoo 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 plushkava.net> Signed-off-by: Sam James 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 }