@@ -13,7 +13,7 @@ source "$SCRIPT_DIR/lib/core/commands.sh"
1313trap cleanup_temp_files EXIT INT TERM
1414
1515# Version and update helpers
16- VERSION=" 1.28.1 "
16+ VERSION=" 1.29.0 "
1717MOLE_TAGLINE=" Deep clean and optimize your Mac."
1818
1919is_touchid_configured () {
@@ -37,6 +37,14 @@ get_latest_version_from_github() {
3737 echo " $version "
3838}
3939
40+ # Check if mole exists in a brew formula list string.
41+ # Args: $1 - brew_list output string
42+ # Returns 0 if "mole" appears as a whole line, 1 otherwise.
43+ _mole_in_brew_list () {
44+ local list=" $1 "
45+ [[ -n " $list " ]] && [[ $' \n ' " $list " $' \n ' == * $' \n ' " mole" $' \n ' * ]]
46+ }
47+
4048# Install detection (Homebrew vs manual).
4149# Uses variable capture + string matching to avoid SIGPIPE under pipefail.
4250is_homebrew_install () {
@@ -49,15 +57,10 @@ is_homebrew_install() {
4957 brew_list=$( brew list --formula 2> /dev/null) || true
5058 fi
5159
52- # Helper to check if mole is in brew list
53- _mole_in_brew_list () {
54- [[ -n " $brew_list " ]] && [[ $' \n ' " $brew_list " $' \n ' == * $' \n ' " mole" $' \n ' * ]]
55- }
56-
5760 if [[ -L " $mole_path " ]]; then
5861 link_target=$( readlink " $mole_path " 2> /dev/null) || true
5962 if [[ " $link_target " == * " Cellar/mole" * ]]; then
60- $has_brew && _mole_in_brew_list && return 0
63+ $has_brew && _mole_in_brew_list " $brew_list " && return 0
6164 return 1
6265 fi
6366 fi
@@ -67,7 +70,7 @@ is_homebrew_install() {
6770 /opt/homebrew/bin/mole | /usr/local/bin/mole)
6871 if [[ -d /opt/homebrew/Cellar/mole ]] || [[ -d /usr/local/Cellar/mole ]]; then
6972 if $has_brew ; then
70- _mole_in_brew_list && return 0
73+ _mole_in_brew_list " $brew_list " && return 0
7174 else
7275 return 0 # Cellar exists, probably Homebrew install
7376 fi
@@ -80,7 +83,7 @@ is_homebrew_install() {
8083 local brew_prefix
8184 brew_prefix=$( brew --prefix 2> /dev/null)
8285 if [[ -n " $brew_prefix " && " $mole_path " == " $brew_prefix /bin/mole" && -d " $brew_prefix /Cellar/mole" ]]; then
83- _mole_in_brew_list && return 0
86+ _mole_in_brew_list " $brew_list " && return 0
8487 fi
8588 fi
8689
0 commit comments