fix: 修复更新时无法选择是否保留上传工具的问题

问题描述:
- 显示了选择菜单,但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 <noreply@anthropic.com>
This commit is contained in:
WanWanYun
2025-11-16 00:21:22 +08:00
parent 2e0376e7e5
commit a9b269af12

View File

@@ -3345,7 +3345,8 @@ update_pull_latest_code() {
echo "║ 2) 删除并重新下载(如果工具有更新) ║" echo "║ 2) 删除并重新下载(如果工具有更新) ║"
echo "╚════════════════════════════════════════════════════════════╝" echo "╚════════════════════════════════════════════════════════════╝"
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} KEEP_UPLOAD_TOOL=${KEEP_UPLOAD_TOOL:-1}
if [[ "$KEEP_UPLOAD_TOOL" == "1" ]]; then if [[ "$KEEP_UPLOAD_TOOL" == "1" ]]; then