From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1534355-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 4096E15800D
	for <garchives@archives.gentoo.org>; Mon,  3 Jul 2023 20:19:07 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 4E8EEE086C;
	Mon,  3 Jul 2023 20:19:06 +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 pigeon.gentoo.org (Postfix) with ESMTPS id 2BD9FE086C
	for <gentoo-commits@lists.gentoo.org>; Mon,  3 Jul 2023 20:19:06 +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 E11CF33BE68
	for <gentoo-commits@lists.gentoo.org>; Mon,  3 Jul 2023 20:19:04 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 02035A74
	for <gentoo-commits@lists.gentoo.org>; Mon,  3 Jul 2023 20:19:03 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
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" <sam@gentoo.org>
Message-ID: <1688415517.f24dd0d9808559571509add2c8c69c1bcb2bfec6.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: f24dd0d9808559571509add2c8c69c1bcb2bfec6
X-VCS-Branch: master
Date: Mon,  3 Jul 2023 20:19:03 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 53b3a558-8ac3-4050-83ae-846c0df2e6ac
X-Archives-Hash: c5c555c00906ed6abec2950714c61346

commit:     f24dd0d9808559571509add2c8c69c1bcb2bfec6
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jun 25 20:03:04 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul  3 20:18:37 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=f24dd0d9

bin/save-ebuild-env.sh: refrain from using the compgen builtin

For the compgen builtin to be available requires that bash be compiled
with --enable-readline. Rather than rely on compgen to generate a list
of function names, parse their names out of declare -F instead.

Specify -v for the following unset command, so that bash is coerced into
unsetting only variables, as is intended.

Expand the applicable variable names with "${!___@}". Owing to the
constraints placed on identifiers, it's not particularly important that
it be done this way, but I think it better expresses the intent.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Bug: https://bugs.gentoo.org/909148
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/save-ebuild-env.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index bba468da1..20cd86866 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -83,8 +83,12 @@ __save_ebuild_env() {
 	___eapi_has_usex && unset -f usex
 
 	# Clear out the triple underscore namespace as it is reserved by the PM.
-	unset -f $(compgen -A function ___)
-	unset ${!___*}
+	while IFS=' ' read -r _ _ REPLY; do
+		if [[ ${REPLY} == ___* ]]; then
+			unset -f "${REPLY}"
+		fi
+	done < <(declare -F)
+	unset -v REPLY "${!___@}"
 
 	# portage config variables and variables set directly by portage
 	unset ACCEPT_LICENSE BUILD_PREFIX COLS \