From a5c5a8d7af33de733687668458588d46670d9053 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 3 Dec 2025 13:56:14 +0800 Subject: [PATCH] Fix optimize compatibility at some times --- lib/clean/user.sh | 7 +++++-- lib/core/common.sh | 12 +++++++++--- mole | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 836ad40..3b89c52 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -213,8 +213,11 @@ clean_application_support_logs() { app_name=$(basename "$app_dir") # Skip system and protected apps - case "$app_name" in - com.apple.* | Adobe* | JetBrains* | 1Password | Claude | *ClashX* | *clash* | mihomo* | *Surge* | iTerm* | *iterm* | Warp* | Kitty* | Alacritty* | WezTerm* | Ghostty*) + # Convert to lowercase for case-insensitive matching + local app_name_lower + app_name_lower=$(echo "$app_name" | tr '[:upper:]' '[:lower:]') + case "$app_name_lower" in + com.apple.* | adobe* | jetbrains* | 1password | claude | *clashx* | *clash* | mihomo* | *surge* | iterm* | warp* | kitty* | alacritty* | wezterm* | ghostty*) continue ;; esac diff --git a/lib/core/common.sh b/lib/core/common.sh index f9b1d3b..2c5780f 100755 --- a/lib/core/common.sh +++ b/lib/core/common.sh @@ -98,13 +98,17 @@ readonly STAT_BSD="/usr/bin/stat" # Get file size in bytes using BSD stat get_file_size() { local file="$1" - $STAT_BSD -f%z "$file" 2> /dev/null || echo 0 + local result + result=$($STAT_BSD -f%z "$file" 2> /dev/null) + echo "${result:-0}" } # Get file modification time (epoch seconds) using BSD stat get_file_mtime() { local file="$1" - $STAT_BSD -f%m "$file" 2> /dev/null || echo 0 + local result + result=$($STAT_BSD -f%m "$file" 2> /dev/null) + echo "${result:-0}" } # Get file owner username using BSD stat @@ -1145,7 +1149,9 @@ clean_tool_cache() { # Returns: size in KB, or 0 if path doesn't exist or error occurs get_path_size_kb() { local path="$1" - du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0" + local result + result=$(du -sk "$path" 2> /dev/null | awk '{print $1}') + echo "${result:-0}" } bytes_to_human_kb() { bytes_to_human "$((${1:-0} * 1024))"; } diff --git a/mole b/mole index 46e0671..5b919b7 100755 --- a/mole +++ b/mole @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/lib/core/common.sh" # Version info -VERSION="1.11.15" +VERSION="1.11.16" MOLE_TAGLINE="can dig deep to clean your Mac." # Check if Touch ID is already configured