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.
This commit is contained in:
Thomas Woerner
2025-05-30 15:55:29 +02:00
parent 89cfb5f4c4
commit 8e3102270d

View File

@@ -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
)