From faa6c58d90b704724bc724e1597f7fde07f1c683 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Sat, 28 Jun 2025 11:07:39 +1000 Subject: [PATCH] Fix: script execution via curl pipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Detect non-interactive execution (curl pipe) and auto-run full install - Use -t 0 to check if stdin is a terminal - Add fallback condition for BASH_SOURCE detection - Ensures one-liner curl command works properly 🤖 Generated with Claude Code Co-Authored-By: Claude --- install.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 973952e..58f05e8 100755 --- a/install.sh +++ b/install.sh @@ -360,15 +360,22 @@ config_only() { print_message "✅ 配置完成!" "$GREEN" } -# 检查是否为交互式调用 -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then +# 主执行逻辑 +main() { # 如果有参数,直接运行完整安装 if [[ $# -gt 0 && $1 == "--full" ]]; then full_install exit 0 fi - # 显示菜单 + # 如果是通过 curl 管道执行(非交互式),默认运行完整安装 + if [[ ! -t 0 ]]; then + print_message "🔍 检测到非交互式执行,运行完整安装..." "$YELLOW" + full_install + exit 0 + fi + + # 交互式菜单 while true; do show_menu @@ -398,4 +405,9 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then ;; esac done +} + +# 只有在脚本被直接执行时才运行主函数 +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] || [[ -z "${BASH_SOURCE[0]}" ]]; then + main "$@" fi \ No newline at end of file