1
0
mirror of https://github.com/dockur/windows.git synced 2026-07-27 21:42:36 +07:00

fix: Select first matching Windows image index (#1942)

This commit is contained in:
Kroese
2026-07-23 22:31:53 +02:00
committed by GitHub
parent 7f1f5510d5
commit b656a8a57f
+2 -20
View File
@@ -235,16 +235,12 @@ getImageIndex() {
local wanted="$2"
local platform tag index name id
local -a matches=()
[ -z "$wanted" ] && return 1
platform=$(getPlatform "$xml")
for tag in DISPLAYNAME PRODUCTNAME NAME; do
matches=()
while IFS=$'\t' read -r index name; do
[ -n "$index" ] || continue
[[ "$name" == *"Operating System"* ]] && continue
@@ -253,7 +249,8 @@ getImageIndex() {
id=$(getVersion "$name" "$platform")
[[ "${id,,}" == "${wanted,,}" ]] || continue
matches+=("$index")
echo "$index"
return 0
done < <(
awk -v tag="$tag" '
/<IMAGE INDEX="/ {
@@ -275,21 +272,6 @@ getImageIndex() {
' <<< "$xml"
)
case "${#matches[@]}" in
0 )
continue
;;
1 )
echo "${matches[0]}"
return 0
;;
* )
# Several WIM entries collapse to the same internal version ID,
# so selecting one of their indexes would be arbitrary.
return 1
;;
esac
done
return 1