From 115b8c4e5695669115e69e036e6b10d87487a074 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 30 May 2024 23:15:38 +0800 Subject: [PATCH] =?UTF-8?q?windows:=20=E6=B7=BB=E5=8A=A0=20image-name=20?= =?UTF-8?q?=E7=BA=A0=E9=94=99=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/trans.sh b/trans.sh index 0cf8aa5..862a0cf 100644 --- a/trans.sh +++ b/trans.sh @@ -2719,14 +2719,34 @@ install_windows() { # 匹配映像版本 # 需要整行匹配,因为要区分 Windows 10 Pro 和 Windows 10 Pro for Workstations - # TODO: 如果无法匹配,等待用户输入?安装第一个? - image_count=$(wiminfo $install_wim | grep "Image Count:" | cut -d: -f2 | xargs) + image_count=$(wiminfo $install_wim | grep "^Image Count:" | cut -d: -f2 | xargs) + all_image_names=$(wiminfo $install_wim | grep ^Name: | sed 's/^Name: *//') + if [ "$image_count" = 1 ]; then - # 只有一个版本就使用第一个版本 - image_name=$(wiminfo $install_wim | grep -ix "Name:[[:space:]]*.*" | cut -d: -f2 | xargs) + # 只有一个版本就用那个版本 + image_name=$all_image_names else - # 否则改成正确的大小写 - image_name=$(wiminfo $install_wim | grep -ix "Name:[[:space:]]*$image_name" | cut -d: -f2 | xargs) + while true; do + # 匹配成功 + # 改成正确的大小写 + if matched_image_name=$(echo "$all_image_names" | grep -ix "$image_name"); then + image_name=$matched_image_name + break + fi + + # 匹配失败 + error "Invalid image name: $image_name" + echo "Choose a correct image name by one of follow command and continue:" + while read -r line; do + echo " echo '$line' >/image-name" + done < <(echo "$all_image_names") + + # sleep 直到有输入 + echo >/image-name + until [ -f /image-name ] && image_name=$(xargs