diff --git a/deploy/lib/common.sh b/deploy/lib/common.sh index e8a6ca2..98f17c9 100644 --- a/deploy/lib/common.sh +++ b/deploy/lib/common.sh @@ -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