mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 01:10:10 +00:00
refactor(uninstall): enhance login item removal and brew UI
- Escape quotes/backslashes in app names for AppleScript safety - Silence osascript stdout to prevent output noise - Capture brew uninstall output to avoid spinner corruption - Log brew errors to debug_log for troubleshooting
This commit is contained in:
@@ -104,7 +104,11 @@ remove_login_item() {
|
|||||||
|
|
||||||
# Remove from Login Items using index-based deletion (handles broken items)
|
# Remove from Login Items using index-based deletion (handles broken items)
|
||||||
if [[ -n "$clean_name" ]]; then
|
if [[ -n "$clean_name" ]]; then
|
||||||
osascript <<- EOF 2> /dev/null || true
|
# Escape double quotes and backslashes for AppleScript
|
||||||
|
local escaped_name="${clean_name//\\/\\\\}"
|
||||||
|
escaped_name="${escaped_name//\"/\\\"}"
|
||||||
|
|
||||||
|
osascript <<- EOF > /dev/null 2>&1 || true
|
||||||
tell application "System Events"
|
tell application "System Events"
|
||||||
try
|
try
|
||||||
set itemCount to count of login items
|
set itemCount to count of login items
|
||||||
@@ -112,7 +116,7 @@ remove_login_item() {
|
|||||||
repeat with i from itemCount to 1 by -1
|
repeat with i from itemCount to 1 by -1
|
||||||
try
|
try
|
||||||
set itemName to name of login item i
|
set itemName to name of login item i
|
||||||
if itemName is "$clean_name" then
|
if itemName is "$escaped_name" then
|
||||||
delete login item i
|
delete login item i
|
||||||
end if
|
end if
|
||||||
end try
|
end try
|
||||||
|
|||||||
@@ -175,9 +175,12 @@ brew_uninstall_cask() {
|
|||||||
|
|
||||||
# Run uninstall with timeout (suppress hints/auto-update)
|
# Run uninstall with timeout (suppress hints/auto-update)
|
||||||
local uninstall_ok=false
|
local uninstall_ok=false
|
||||||
if HOMEBREW_NO_ENV_HINTS=1 HOMEBREW_NO_AUTO_UPDATE=1 NONINTERACTIVE=1 \
|
local output
|
||||||
run_with_timeout 120 brew uninstall --cask "$cask_name" 2>&1; then
|
if output=$(HOMEBREW_NO_ENV_HINTS=1 HOMEBREW_NO_AUTO_UPDATE=1 NONINTERACTIVE=1 \
|
||||||
|
run_with_timeout 120 brew uninstall --cask "$cask_name" 2>&1); then
|
||||||
uninstall_ok=true
|
uninstall_ok=true
|
||||||
|
else
|
||||||
|
debug_log "brew uninstall output: $output"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify removal
|
# Verify removal
|
||||||
|
|||||||
Reference in New Issue
Block a user