mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
fix brew uninstall fallback consistency
This commit is contained in:
@@ -35,6 +35,21 @@ is_homebrew_available() {
|
||||
command -v brew > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Check whether a cask is still recorded as installed in Homebrew.
|
||||
# Exit codes:
|
||||
# 0 - cask is installed
|
||||
# 1 - cask is not installed
|
||||
# 2 - install state could not be determined
|
||||
is_brew_cask_installed() {
|
||||
local cask_name="$1"
|
||||
[[ -n "$cask_name" ]] || return 2
|
||||
is_homebrew_available || return 2
|
||||
|
||||
local cask_list
|
||||
cask_list=$(HOMEBREW_NO_ENV_HINTS=1 brew list --cask 2> /dev/null) || return 2
|
||||
grep -qxF "$cask_name" <<< "$cask_list"
|
||||
}
|
||||
|
||||
# Extract cask token from a Caskroom path
|
||||
# Args: $1 - path (must be inside Caskroom)
|
||||
# Prints: cask token to stdout
|
||||
@@ -211,7 +226,12 @@ brew_uninstall_cask() {
|
||||
|
||||
# Verify removal (only if not timed out)
|
||||
local cask_gone=true app_gone=true
|
||||
HOMEBREW_NO_ENV_HINTS=1 brew list --cask 2> /dev/null | grep -qxF "$cask_name" && cask_gone=false
|
||||
if is_brew_cask_installed "$cask_name"; then
|
||||
cask_gone=false
|
||||
else
|
||||
local cask_state=$?
|
||||
[[ $cask_state -eq 1 ]] || cask_gone=false
|
||||
fi
|
||||
[[ -n "$app_path" && -e "$app_path" ]] && app_gone=false
|
||||
|
||||
# Success: uninstall worked and both are gone, or already uninstalled
|
||||
|
||||
Reference in New Issue
Block a user