Fix: script execution via curl pipe

- 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 <noreply@anthropic.com>
This commit is contained in:
Astrian Zheng 2025-06-28 11:07:39 +10:00
parent bc50c78353
commit faa6c58d90
Signed by: Astrian
SSH Key Fingerprint: SHA256:rVnhx3DAKjujCwWE13aDl7uV6+9U1MvydLkNRXJrBiA

View File

@ -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