From 751fae1343d75c63a0595974686c8fe62d582831 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 7 Aug 2026 06:40:13 +0200 Subject: [PATCH] fix: Handle answer files without product keys (#2097) --- src/answer.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/answer.sh b/src/answer.sh index c5ea5df3..0012bce4 100644 --- a/src/answer.sh +++ b/src/answer.sh @@ -1198,7 +1198,15 @@ removeEmbeddedProductKeys() { local product_keys='//u:ProductKey' local separator=$'\x1f' delete_xpath="" - local records position child_key direct_key + local count records position child_key direct_key + + count=$(xmlstarlet sel \ + -N "$XML_NS_UNATTEND_ARG" -T -t \ + -v "count($product_keys)" \ + "$asset") || return 1 + + [[ "$count" =~ ^[0-9]+$ ]] || return 1 + (( count == 0 )) && return 0 records=$(xmlstarlet sel \ -N "$XML_NS_UNATTEND_ARG" -T -t \