From cd5b1813cbbd9cddb7f49c255c6606788a29b0b7 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Wed, 15 Jul 2026 21:54:45 +0300
Subject: trinity-functions-2.eclass: avoid using herestring

Since portage now enforces sandboxing policies during depend faze, usage
of heredoc in trinity_remove_path_component() results in violation of
said policy because internally bash uses a temporary file for that.

Probably we should be avoiding modifying PATHs in global scope all
together but that would be too drastic of a change.

Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tde-packaging-gentoo/issues/516
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 eclass/trinity-functions-2.eclass | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/eclass/trinity-functions-2.eclass b/eclass/trinity-functions-2.eclass
index 61491330..806df5e9 100644
--- a/eclass/trinity-functions-2.eclass
+++ b/eclass/trinity-functions-2.eclass
@@ -116,16 +116,18 @@ adjust-trinity-paths() {
 # @DESCRIPTION:
 # Removes the specified path from the PATH variable.
 trinity_remove_path_component() {
-	local i new_path path_array
+	local i new_path old_ifs
 
-	IFS=: read -ra path_array <<< "${1}"
-	for i in "${path_array[@]}"; do
+	old_ifs=$IFS
+	IFS=":"
+	for i in ${1}; do
 		case "${i}" in
 			${2} ) ;; # delete specyfied entry
 			"" ) ;;
 			* ) new_path="${new_path}:${i}" ;;
 		esac
 	done
+	IFS="${old_ifs}"
 
 	echo "${new_path#:}"
 }
-- 
cgit v1.2.3

