From 0aa51cc9320429d2ba623570fc9eabcaadae7cb5 Mon Sep 17 00:00:00 2001 From: xiaobai Date: Thu, 26 Feb 2026 21:27:23 +0800 Subject: [PATCH] refactor: Simplify parameter parsing in install script - Move the parameter parsing for force installation to a more logical position in the script, ensuring it executes before displaying the running mode. - Remove redundant code related to force installation parameter parsing, improving script clarity and maintainability. --- install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index c67c5d2..7146d4a 100644 --- a/install.sh +++ b/install.sh @@ -23,6 +23,15 @@ CONFIG_DIR="/etc/funmc" DATA_DIR="/var/lib/funmc" LOG_DIR="/var/log/funmc" +# 先解析参数(必须在显示运行模式前执行) +FORCE_INSTALL=0 +for arg in "$@"; do + if [ "$arg" = "-force" ] || [ "$arg" = "--force" ]; then + FORCE_INSTALL=1 + break + fi +done + echo -e "${CYAN}" echo "╔═══════════════════════════════════════════════════════════╗" echo "║ ║" @@ -46,15 +55,6 @@ if [ "$EUID" -ne 0 ]; then exit 1 fi -# 解析参数:-force 或 --force 为强制覆盖安装,否则为更新(不覆盖数据) -FORCE_INSTALL=0 -for arg in "$@"; do - if [ "$arg" = "-force" ] || [ "$arg" = "--force" ]; then - FORCE_INSTALL=1 - break - fi -done - # 检测系统 detect_os() { if [ -f /etc/os-release ]; then