From 708285a2ef55c0422720320e3db562d208801c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=85=8E=E9=A5=BC=E6=9E=9C=E5=AD=90=E5=8D=B7=E9=B2=A8?= =?UTF-8?q?=E9=B1=BC=E8=BE=A3=E6=A4=92?= Date: Sat, 25 Jan 2025 20:16:56 +0800 Subject: [PATCH] Refactor disable_auto_update() function in Linux script - Improved error handling logic with more concise conditional checks - Replaced complex multi-line command with an if statement for better readability - Simplified file permission and ownership setting validation - Maintained existing error logging and manual guide display functionality --- scripts/run/cursor_linux_id_modifier.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/run/cursor_linux_id_modifier.sh b/scripts/run/cursor_linux_id_modifier.sh index 920f204..a0fe5db 100644 --- a/scripts/run/cursor_linux_id_modifier.sh +++ b/scripts/run/cursor_linux_id_modifier.sh @@ -295,12 +295,11 @@ disable_auto_update() { return 1 } - chmod 444 "$updater_path" 2>/dev/null && \ - chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null || { + if ! chmod 444 "$updater_path" 2>/dev/null || ! chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null; then log_error "设置文件权限失败" show_manual_guide return 1 - } + fi # 尝试设置不可修改属性 if command -v chattr &> /dev/null; then @@ -316,7 +315,7 @@ disable_auto_update() { log_error "验证失败:文件权限设置可能未生效" show_manual_guide return 1 - } + fi log_info "成功禁用自动更新" else