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" ]]
}