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:
parent
bc50c78353
commit
faa6c58d90
18
install.sh
18
install.sh
|
@ -360,15 +360,22 @@ config_only() {
|
||||||
print_message "✅ 配置完成!" "$GREEN"
|
print_message "✅ 配置完成!" "$GREEN"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查是否为交互式调用
|
# 主执行逻辑
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
main() {
|
||||||
# 如果有参数,直接运行完整安装
|
# 如果有参数,直接运行完整安装
|
||||||
if [[ $# -gt 0 && $1 == "--full" ]]; then
|
if [[ $# -gt 0 && $1 == "--full" ]]; then
|
||||||
full_install
|
full_install
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 显示菜单
|
# 如果是通过 curl 管道执行(非交互式),默认运行完整安装
|
||||||
|
if [[ ! -t 0 ]]; then
|
||||||
|
print_message "🔍 检测到非交互式执行,运行完整安装..." "$YELLOW"
|
||||||
|
full_install
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 交互式菜单
|
||||||
while true; do
|
while true; do
|
||||||
show_menu
|
show_menu
|
||||||
|
|
||||||
|
@ -398,4 +405,9 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# 只有在脚本被直接执行时才运行主函数
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]] || [[ -z "${BASH_SOURCE[0]}" ]]; then
|
||||||
|
main "$@"
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue
Block a user