From a9b269af12e344468dcc19d7172575bf1cdc7023 Mon Sep 17 00:00:00 2001 From: WanWanYun Date: Sun, 16 Nov 2025 00:21:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E6=97=A0=E6=B3=95=E9=80=89=E6=8B=A9=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=8A=E4=BC=A0=E5=B7=A5=E5=85=B7=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题描述: - 显示了选择菜单,但read命令直接跳过 - 无法输入选择,直接使用默认值1 - 用户想选择2也无法输入 原因分析: - update流程中标准输入可能被重定向或被其他命令消耗 - read命令从stdin读取时可能读到空输入 - 导致直接使用默认值 解决方案: 使用 `< /dev/tty` 强制从终端读取: ```bash read -p "▶ 请选择 [1/2, 默认:1]: " KEEP_UPLOAD_TOOL < /dev/tty ``` 工作原理: - /dev/tty: 当前终端设备 - < /dev/tty: 强制从终端读取输入 - 即使stdin被重定向,仍能从终端获取用户输入 测试建议: 运行 bash install.sh update 时: 1. 显示选择菜单 2. 等待用户输入 3. 输入1: 保留工具 4. 输入2: 重新下载 5. 直接回车: 使用默认值1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 81810a4..2b5ead5 100644 --- a/install.sh +++ b/install.sh @@ -3345,7 +3345,8 @@ update_pull_latest_code() { echo "║ 2) 删除并重新下载(如果工具有更新) ║" echo "╚════════════════════════════════════════════════════════════╝" echo "" - read -p "▶ 请选择 [1/2, 默认:1]: " KEEP_UPLOAD_TOOL + # 强制从终端读取用户输入 + read -p "▶ 请选择 [1/2, 默认:1]: " KEEP_UPLOAD_TOOL < /dev/tty KEEP_UPLOAD_TOOL=${KEEP_UPLOAD_TOOL:-1} if [[ "$KEEP_UPLOAD_TOOL" == "1" ]]; then