diff --git a/lib/clean/apps.sh b/lib/clean/apps.sh index 8aa0aea..1093f33 100644 --- a/lib/clean/apps.sh +++ b/lib/clean/apps.sh @@ -326,11 +326,6 @@ clean_orphaned_system_services() { start_section_spinner "Scanning orphaned system services..." - # Build list of installed app bundle IDs - local installed_bundles - installed_bundles=$(create_temp_file) - scan_installed_apps "$installed_bundles" - local orphaned_count=0 local total_orphaned_kb=0 local -a orphaned_files=() @@ -467,5 +462,4 @@ clean_orphaned_system_services() { note_activity fi - rm -f "$installed_bundles" } diff --git a/lib/core/ui.sh b/lib/core/ui.sh index f9a8ea0..ef44d92 100755 --- a/lib/core/ui.sh +++ b/lib/core/ui.sh @@ -220,7 +220,6 @@ read_key() { case "$key" in $'\n' | $'\r') echo "ENTER" ;; ' ') echo "SPACE" ;; - '/') echo "FILTER" ;; 'q' | 'Q') echo "QUIT" ;; 'R') echo "RETRY" ;; 'm' | 'M') echo "MORE" ;; diff --git a/lib/uninstall/batch.sh b/lib/uninstall/batch.sh index 5084137..87014a1 100755 --- a/lib/uninstall/batch.sh +++ b/lib/uninstall/batch.sh @@ -169,15 +169,32 @@ remove_file_list() { batch_uninstall_applications() { local total_size_freed=0 - # Trap to clean up spinner and uninstall mode on interrupt - trap 'stop_inline_spinner 2>/dev/null; unset MOLE_UNINSTALL_MODE; echo ""; return 130' INT TERM - # shellcheck disable=SC2154 if [[ ${#selected_apps[@]} -eq 0 ]]; then log_warning "No applications selected for uninstallation" return 0 fi + local old_trap_int old_trap_term + old_trap_int=$(trap -p INT) + old_trap_term=$(trap -p TERM) + + _restore_uninstall_traps() { + if [[ -n "$old_trap_int" ]]; then + eval "$old_trap_int" + else + trap - INT + fi + if [[ -n "$old_trap_term" ]]; then + eval "$old_trap_term" + else + trap - TERM + fi + } + + # Trap to clean up spinner and uninstall mode on interrupt + trap 'stop_inline_spinner 2>/dev/null; unset MOLE_UNINSTALL_MODE; echo ""; _restore_uninstall_traps; return 130' INT TERM + # Pre-scan: running apps, sudo needs, size. local -a running_apps=() local -a sudo_apps=() @@ -348,6 +365,7 @@ batch_uninstall_applications() { $'\e' | q | Q) echo "" echo "" + _restore_uninstall_traps return 0 ;; "" | $'\n' | $'\r' | y | Y) @@ -356,6 +374,7 @@ batch_uninstall_applications() { *) echo "" echo "" + _restore_uninstall_traps return 0 ;; esac @@ -370,6 +389,7 @@ batch_uninstall_applications() { if ! request_sudo_access "Admin required for system apps: ${sudo_apps[*]}"; then echo "" log_error "Admin access denied" + _restore_uninstall_traps return 1 fi fi @@ -648,6 +668,9 @@ batch_uninstall_applications() { rm -f "$cache_file" 2> /dev/null || true fi + _restore_uninstall_traps + unset -f _restore_uninstall_traps + ((total_size_cleaned += total_size_freed)) unset failed_items }