From 8e3102270d0431a16e6b8864e6801d86931db864 Mon Sep 17 00:00:00 2001
From: Thomas Woerner <twoerner@redhat.com>
Date: Fri, 30 May 2025 15:55:29 +0200
Subject: [PATCH] infra/image/shcontainer: Safer host removal from /etc/hosts

The sed command for host removal from PR #1364 is used now. This makes
sure that only full matches are removed and not substring matches.
---
 infra/image/shcontainer | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/infra/image/shcontainer b/infra/image/shcontainer
index 6e387cde..063b2720 100644
--- a/infra/image/shcontainer
+++ b/infra/image/shcontainer
@@ -60,7 +60,7 @@ container_start() {
     hostname=$(podman inspect "${name}" --format "{{.Config.Hostname}}")
     if [ -n "${ip}" ] && [ -n "${hostname}" ]; then
         cmd=$(cat <<EOF
-sed -i -e "/[ \t]${hostname}/d" /etc/hosts
+sed -i -E "/\s+${hostname}(\s|$)/d" /etc/hosts
 echo -e "$ip\t${hostname} ${hostname%%.*}" >> /etc/hosts
 EOF
            )
-- 
GitLab