Skip to content

Commit 708285a

Browse files
committed
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
1 parent 2cfd7e6 commit 708285a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

scripts/run/cursor_linux_id_modifier.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,11 @@ disable_auto_update() {
295295
return 1
296296
}
297297

298-
chmod 444 "$updater_path" 2>/dev/null && \
299-
chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null || {
298+
if ! chmod 444 "$updater_path" 2>/dev/null || ! chown "$CURRENT_USER:$CURRENT_USER" "$updater_path" 2>/dev/null; then
300299
log_error "设置文件权限失败"
301300
show_manual_guide
302301
return 1
303-
}
302+
fi
304303

305304
# 尝试设置不可修改属性
306305
if command -v chattr &> /dev/null; then
@@ -316,7 +315,7 @@ disable_auto_update() {
316315
log_error "验证失败:文件权限设置可能未生效"
317316
show_manual_guide
318317
return 1
319-
}
318+
fi
320319

321320
log_info "成功禁用自动更新"
322321
else

0 commit comments

Comments
 (0)