mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:50:06 +00:00
This commit addresses the issue #506 where mole would exit prematurely during application support scanning. Changes: 1. Remove 4 redundant pipefail disable/restore blocks: - safe_find_delete() in lib/core/file_ops.sh - safe_sudo_find_delete() in lib/core/file_ops.sh - fix_broken_preferences() in lib/optimize/maintenance.sh - opt_saved_state_cleanup() in lib/optimize/tasks.sh These were unnecessary because process substitution (< <(cmd)) is not affected by pipefail - only real pipelines (cmd1 | cmd2) are. 2. Fix real bug in fix_broken_preferences(): - Add || true to ((broken_count++)) on lines 35 and 55 - This prevents set -e from exiting when broken_count starts at 0 Fixes #506
54 lines
1.5 KiB
Bash
54 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# System Configuration Maintenance Module.
|
|
# Fix broken preferences and login items.
|
|
|
|
set -euo pipefail
|
|
|
|
# Remove corrupted preference files.
|
|
fix_broken_preferences() {
|
|
local prefs_dir="$HOME/Library/Preferences"
|
|
[[ -d "$prefs_dir" ]] || return 0
|
|
|
|
local broken_count=0
|
|
|
|
while IFS= read -r plist_file; do
|
|
[[ -f "$plist_file" ]] || continue
|
|
|
|
local filename
|
|
filename=$(basename "$plist_file")
|
|
case "$filename" in
|
|
com.apple.* | .GlobalPreferences* | loginwindow.plist)
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
plutil -lint "$plist_file" > /dev/null 2>&1 && continue
|
|
|
|
safe_remove "$plist_file" true > /dev/null 2>&1 || true
|
|
((broken_count++)) || true
|
|
done < <(command find "$prefs_dir" -maxdepth 1 -name "*.plist" -type f 2> /dev/null || true)
|
|
|
|
# Check ByHost preferences.
|
|
local byhost_dir="$prefs_dir/ByHost"
|
|
if [[ -d "$byhost_dir" ]]; then
|
|
while IFS= read -r plist_file; do
|
|
[[ -f "$plist_file" ]] || continue
|
|
|
|
local filename
|
|
filename=$(basename "$plist_file")
|
|
case "$filename" in
|
|
com.apple.* | .GlobalPreferences*)
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
plutil -lint "$plist_file" > /dev/null 2>&1 && continue
|
|
|
|
safe_remove "$plist_file" true > /dev/null 2>&1 || true
|
|
((broken_count++)) || true
|
|
done < <(command find "$byhost_dir" -name "*.plist" -type f 2> /dev/null || true)
|
|
fi
|
|
|
|
echo "$broken_count"
|
|
}
|