mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 20:25:04 +00:00
Improve spinner subprocess and trap cleanup handling
This commit is contained in:
@@ -10,8 +10,6 @@ export LANG=C
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../lib/core/common.sh"
|
source "$SCRIPT_DIR/../lib/core/common.sh"
|
||||||
|
|
||||||
# Set up cleanup trap for temporary files
|
|
||||||
trap cleanup_temp_files EXIT INT TERM
|
|
||||||
source "$SCRIPT_DIR/../lib/core/sudo.sh"
|
source "$SCRIPT_DIR/../lib/core/sudo.sh"
|
||||||
source "$SCRIPT_DIR/../lib/clean/brew.sh"
|
source "$SCRIPT_DIR/../lib/clean/brew.sh"
|
||||||
source "$SCRIPT_DIR/../lib/clean/caches.sh"
|
source "$SCRIPT_DIR/../lib/clean/caches.sh"
|
||||||
@@ -137,6 +135,9 @@ cleanup() {
|
|||||||
printf "\r\033[K" >&2
|
printf "\r\033[K" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up temporary files
|
||||||
|
cleanup_temp_files
|
||||||
|
|
||||||
# Stop sudo session
|
# Stop sudo session
|
||||||
stop_sudo_session
|
stop_sudo_session
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,8 @@ scan_applications() {
|
|||||||
|
|
||||||
local spinner_pid=""
|
local spinner_pid=""
|
||||||
(
|
(
|
||||||
trap 'exit 0' TERM INT EXIT
|
cleanup_spinner() { exit 0; }
|
||||||
|
trap cleanup_spinner TERM INT EXIT
|
||||||
local spinner_chars="|/-\\"
|
local spinner_chars="|/-\\"
|
||||||
local i=0
|
local i=0
|
||||||
while true; do
|
while true; do
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ scan_applications() {
|
|||||||
# Start a background spinner that reads progress from file
|
# Start a background spinner that reads progress from file
|
||||||
local spinner_pid=""
|
local spinner_pid=""
|
||||||
(
|
(
|
||||||
trap 'exit 0' TERM INT EXIT
|
cleanup_spinner() { exit 0; }
|
||||||
|
trap cleanup_spinner TERM INT EXIT
|
||||||
local spinner_chars="|/-\\"
|
local spinner_chars="|/-\\"
|
||||||
local i=0
|
local i=0
|
||||||
while true; do
|
while true; do
|
||||||
|
|||||||
@@ -241,12 +241,9 @@ clean_remote_desktop() {
|
|||||||
|
|
||||||
# Main function to clean all user GUI applications
|
# Main function to clean all user GUI applications
|
||||||
clean_user_gui_applications() {
|
clean_user_gui_applications() {
|
||||||
start_section_spinner "Scanning app caches..."
|
|
||||||
|
|
||||||
clean_xcode_tools
|
|
||||||
|
|
||||||
stop_section_spinner
|
stop_section_spinner
|
||||||
|
|
||||||
|
clean_xcode_tools
|
||||||
clean_code_editors
|
clean_code_editors
|
||||||
clean_communication_apps
|
clean_communication_apps
|
||||||
clean_dingtalk
|
clean_dingtalk
|
||||||
|
|||||||
@@ -255,7 +255,10 @@ start_inline_spinner() {
|
|||||||
|
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
(
|
(
|
||||||
trap 'exit 0' TERM INT EXIT
|
# Clean exit handler for spinner subprocess
|
||||||
|
cleanup_spinner() { exit 0; }
|
||||||
|
trap cleanup_spinner TERM INT EXIT
|
||||||
|
|
||||||
local chars
|
local chars
|
||||||
chars="$(mo_spinner_chars)"
|
chars="$(mo_spinner_chars)"
|
||||||
[[ -z "$chars" ]] && chars="|/-\\"
|
[[ -z "$chars" ]] && chars="|/-\\"
|
||||||
|
|||||||
Reference in New Issue
Block a user