From 013549ad256dcf1b660425274bd86f8786583895 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Fri, 27 Feb 2026 22:52:38 +0800 Subject: [PATCH] fix: temporarily disable pipefail to prevent process substitution failures during cleanup operations --- lib/clean/user.sh | 10 ++++++++++ lib/core/file_ops.sh | 24 ++++++++++++++++++++++++ lib/optimize/maintenance.sh | 12 ++++++++++++ lib/optimize/tasks.sh | 12 ++++++++++++ 4 files changed, 58 insertions(+) diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 8a6f585..52fd322 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -793,6 +793,12 @@ clean_application_support_logs() { [[ "$total_apps" =~ ^[0-9]+$ ]] || total_apps=0 local last_progress_update last_progress_update=$(get_epoch_seconds) + # Temporarily disable pipefail to prevent process substitution failures from interrupting the scan + local pipefail_was_set=false + if [[ -o pipefail ]]; then + pipefail_was_set=true + set +o pipefail + fi for app_dir in ~/Library/Application\ Support/*; do [[ -d "$app_dir" ]] || continue local app_name @@ -917,6 +923,10 @@ clean_application_support_logs() { fi done done + # Restore pipefail if it was previously set + if [[ "$pipefail_was_set" == "true" ]]; then + set -o pipefail + fi eval "$_ng_state" stop_section_spinner if [[ "$found_any" == "true" ]]; then diff --git a/lib/core/file_ops.sh b/lib/core/file_ops.sh index fc5cfee..e99e628 100644 --- a/lib/core/file_ops.sh +++ b/lib/core/file_ops.sh @@ -434,6 +434,13 @@ 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 @@ -442,6 +449,11 @@ 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 } @@ -481,6 +493,13 @@ 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 @@ -489,6 +508,11 @@ 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 } diff --git a/lib/optimize/maintenance.sh b/lib/optimize/maintenance.sh index 0cad6b3..4e5dc0c 100644 --- a/lib/optimize/maintenance.sh +++ b/lib/optimize/maintenance.sh @@ -11,6 +11,13 @@ fix_broken_preferences() { local broken_count=0 + # 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 + while IFS= read -r plist_file; do [[ -f "$plist_file" ]] || continue @@ -49,5 +56,10 @@ fix_broken_preferences() { done < <(command find "$byhost_dir" -name "*.plist" -type f 2> /dev/null || true) fi + # Restore pipefail if it was previously set + if [[ "$pipefail_was_set" == "true" ]]; then + set -o pipefail + fi + echo "$broken_count" } diff --git a/lib/optimize/tasks.sh b/lib/optimize/tasks.sh index 6260263..42d27e6 100644 --- a/lib/optimize/tasks.sh +++ b/lib/optimize/tasks.sh @@ -191,12 +191,24 @@ opt_saved_state_cleanup() { local state_dir="$HOME/Library/Saved Application State" if [[ -d "$state_dir" ]]; then + # 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 + while IFS= read -r -d '' state_path; do if should_protect_path "$state_path"; then continue fi safe_remove "$state_path" true > /dev/null 2>&1 || true done < <(command find "$state_dir" -type d -name "*.savedState" -mtime "+$MOLE_SAVED_STATE_AGE_DAYS" -print0 2> /dev/null) + + # Restore pipefail if it was previously set + if [[ "$pipefail_was_set" == "true" ]]; then + set -o pipefail + fi fi opt_msg "App saved states optimized"