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
+20 -3
View File
@@ -31,6 +31,22 @@ unset _script_src
set -u
# curl | bash: stdin 为管道,clone 后或已有仓库时改从终端读入
reexec_with_tty_if_needed() {
if [[ -t 0 ]]; then
return 0
fi
local script=""
if [[ -f "${INSTALL_ROOT}/deploy/manage.sh" ]]; then
script="${INSTALL_ROOT}/deploy/manage.sh"
elif [[ -n "${DEPLOY_DIR}" && -f "${DEPLOY_DIR}/manage.sh" ]]; then
script="${DEPLOY_DIR}/manage.sh"
fi
if [[ -n "${script}" ]]; then
exec bash "${script}" "$@" </dev/tty
fi
}
repo_ready() {
[[ -f "${1}/deploy/setup_env.sh" && -f "${1}/deploy/manage.sh" ]]
}
@@ -71,7 +87,7 @@ bootstrap_repo() {
fi
mkdir -p "$(dirname "${INSTALL_ROOT}")"
git clone -b "${GIT_BRANCH}" "${GIT_URL}" "${INSTALL_ROOT}"
exec bash "${INSTALL_ROOT}/deploy/manage.sh" "$@"
exec bash "${INSTALL_ROOT}/deploy/manage.sh" "$@" </dev/tty
}
show_banner() {
@@ -113,7 +129,7 @@ main_menu() {
show_banner
show_menu
local choice=""
read -r -p "请选择 [0-3]: " choice
cm_read choice "请选择 [0-3]: "
case "${choice}" in
1)
bash "${LIB_DIR}/install.sh"
@@ -133,8 +149,9 @@ main_menu() {
;;
esac
echo ""
read -r -p "按 Enter 返回菜单..." _
cm_read _ "按 Enter 返回菜单..."
done
}
reexec_with_tty_if_needed "$@"
main_menu "$@"