mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 22:30:08 +00:00
fix: remove redundant pipefail blocks and fix arithmetic bug
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
This commit is contained in:
@@ -434,13 +434,6 @@ safe_find_delete() {
|
||||
find_args+=("-mtime" "+$age_days")
|
||||
fi
|
||||
|
||||
# Temporarily disable pipefail to prevent process substitution failures from interrupting
|
||||
local pipefail_was_set=false
|
||||
if [[ -o pipefail ]]; then
|
||||
pipefail_was_set=true
|
||||
set +o pipefail
|
||||
fi
|
||||
|
||||
# Iterate results to respect should_protect_path
|
||||
while IFS= read -r -d '' match; do
|
||||
if should_protect_path "$match"; then
|
||||
@@ -449,11 +442,6 @@ safe_find_delete() {
|
||||
safe_remove "$match" true || true
|
||||
done < <(command find "$base_dir" "${find_args[@]}" -print0 2> /dev/null || true)
|
||||
|
||||
# Restore pipefail if it was previously set
|
||||
if [[ "$pipefail_was_set" == "true" ]]; then
|
||||
set -o pipefail
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -493,13 +481,6 @@ safe_sudo_find_delete() {
|
||||
find_args+=("-mtime" "+$age_days")
|
||||
fi
|
||||
|
||||
# Temporarily disable pipefail to prevent process substitution failures from interrupting
|
||||
local pipefail_was_set=false
|
||||
if [[ -o pipefail ]]; then
|
||||
pipefail_was_set=true
|
||||
set +o pipefail
|
||||
fi
|
||||
|
||||
# Iterate results to respect should_protect_path
|
||||
while IFS= read -r -d '' match; do
|
||||
if should_protect_path "$match"; then
|
||||
@@ -508,11 +489,6 @@ safe_sudo_find_delete() {
|
||||
safe_sudo_remove "$match" || true
|
||||
done < <(sudo find "$base_dir" "${find_args[@]}" -print0 2> /dev/null || true)
|
||||
|
||||
# Restore pipefail if it was previously set
|
||||
if [[ "$pipefail_was_set" == "true" ]]; then
|
||||
set -o pipefail
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user