fix: when piped via curl|bash/irm|iex without flags, enter interactive menu instead of exiting

This commit is contained in:
i
2026-06-02 22:19:59 +08:00
parent 93d0adee9e
commit 6f1408ac68
2 changed files with 13 additions and 11 deletions
+3 -7
View File
@@ -1069,14 +1069,10 @@ try {
Start-Sleep 3
return
}
if (-not $script:STATUS_CLI_INSTALLED) {
Write-Host ""
Write-Warn "HAPI CLI 未安装"
Write-Warn "请使用 -Source / -Force 等参数指定操作,或直接运行 install.ps1 进入交互模式"
}
# 无参数时进入交互菜单(Read-Host 在 iex 模式下仍可读取控制台输入)
Write-Host ""
Write-Info "检测到管道执行,自动进入交互模式"
Write-Host ""
Start-Sleep 3
return
}
# 交互菜单
+10 -4
View File
@@ -1416,12 +1416,18 @@ main() {
perform_install
exit $?
fi
if [[ "$STATUS_CLI_INSTALLED" != true ]]; then
# 无参数时尝试打开 /dev/tty 进入交互菜单
if [[ -c /dev/tty ]]; then
exec </dev/tty
else
echo ""
warn "HAPI CLI 未安装"
warn "请使用 --source / --force 等参数指定操作,或直接运行 bash install.sh 进入交互模式"
if [[ "$STATUS_CLI_INSTALLED" != true ]]; then
warn "HAPI CLI 未安装,请使用 --source / --force 等参数指定操作"
else
info "提示: 直接运行 bash install.sh 进入交互模式,或使用 --help 查看命令参数"
fi
exit 0
fi
exit 0
fi
# 交互菜单