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 D5ED9158074 for ; Sat, 28 Jun 2025 02:31:09 +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) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id C1BEF340E5B for ; Sat, 28 Jun 2025 02:31:09 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 9AEC511056D; Sat, 28 Jun 2025 02:30:39 +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) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 8C319110569 for ; Sat, 28 Jun 2025 02:30:39 +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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 47851340EC7 for ; Sat, 28 Jun 2025 02:30:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 274ED2AB2 for ; Sat, 28 Jun 2025 02:30:36 +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: <1751077821.0b4f4a0bf19b6a069a74883bf8ad5ba4be3ed0f4.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/save-ebuild-env.sh X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 0b4f4a0bf19b6a069a74883bf8ad5ba4be3ed0f4 X-VCS-Branch: master Date: Sat, 28 Jun 2025 02:30:36 +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: e8681f66-a634-4888-88d5-5b6b810984c6 X-Archives-Hash: 7d6544f519da0ca24d730e0db7f74741 commit: 0b4f4a0bf19b6a069a74883bf8ad5ba4be3ed0f4 Author: Kerin Millar plushkava net> AuthorDate: Fri Jun 27 06:06:01 2025 +0000 Commit: Sam James gentoo org> CommitDate: Sat Jun 28 02:30:21 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0b4f4a0b save-ebuild-env-sh: refrain from assigning to and unsetting x Presently, the __save_ebuild_env() function uses the 'x' variable to iterate over various function names before proceeding to unset it. To do so is inadvisable because variables are dynamically scoped in bash and there may be no guarantee that 'x' wasn't already declared. Hence, the use of the unset builtin can be dangerous, since it can have the effect of unmasking a variable from a previous scope. $ var=1 $ x() { local var=2; y; } $ y() { var=3; unset var; declare -p var; } $ x declare -- var="1" Address this issue by instead having the applicable for loop use the special '_' parameter as a topic variable. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/save-ebuild-env.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index f39c24eb90..5d5d25bbd7 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -42,12 +42,11 @@ __save_ebuild_env() ( # There's no need to bloat environment.bz2 with internally defined # functions and variables, so filter them out if possible. - for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \ + for _ in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \ src_compile src_test src_install pkg_preinst pkg_postinst \ pkg_prerm pkg_postrm pkg_config pkg_info pkg_pretend ; do - unset -f default_${x} __eapi{0,1,2,4,6,8}_${x} + unset -f default_${_} __eapi{0,1,2,4,6,8}_${_} done - unset x unset -f assert __assert_sigpipe_ok \ __dump_trace die \