Fix curl-pipe menu exiting immediately by reading from /dev/tty.

Re-exec manage.sh with terminal stdin after clone or when repo exists, and route all prompts through cm_read.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-12 12:36:34 +08:00
parent 95895d53b6
commit acb61a413b
4 changed files with 37 additions and 7 deletions
+15 -2
View File
@@ -87,17 +87,30 @@ detect_server_ip() {
confirm_yes() {
local msg="$1"
local ans=""
read -r -p "${msg} [y/N] " ans
cm_read ans "${msg} [y/N] "
[[ "${ans}" == [yY] || "${ans}" == [yY][eE][sS] ]]
}
confirm_uninstall() {
local ans=""
echo "此操作将停止全部 PM2 进程并移走安装目录."
read -r -p "输入 UNINSTALL 确认卸载: " ans
cm_read ans "输入 UNINSTALL 确认卸载: "
[[ "${ans}" == "UNINSTALL" ]]
}
# curl | bash 时 stdin 是管道,须从 /dev/tty 读取用户输入
cm_read() {
local __var="$1"
local __prompt="$2"
local __val=""
if [[ -r /dev/tty ]]; then
IFS= read -r -p "${__prompt}" __val </dev/tty || true
else
IFS= read -r -p "${__prompt}" __val || true
fi
printf -v "${__var}" '%s' "${__val}"
}
repo_ready() {
[[ -f "${1}/deploy/setup_env.sh" && -f "${1}/deploy/manage.sh" ]]
}
+1 -1
View File
@@ -52,7 +52,7 @@ handle_existing_install() {
echo " b) 修复环境(重建 venv,保留 .env 与数据库)"
echo " c) 深度重装(保留 .env,清库,见 reinstall.sh)"
local choice=""
read -r -p "请选择 [a/b/c]: " choice
cm_read choice "请选择 [a/b/c]: "
case "${choice}" in
b|B)
install_repair
+1 -1
View File
@@ -59,7 +59,7 @@ show_update_menu() {
echo " 3-3) 深度重装(保留 .env,清库)"
echo " 0) 返回主菜单"
local choice=""
read -r -p "请选择 [0/3-1/3-2/3-3]: " choice
cm_read choice "请选择 [0/3-1/3-2/3-3]: "
case "${choice}" in
3-1|31|1) update_quick; break ;;
3-2|32|2) update_deps; break ;;