From cac29090930a85c51c661f2fad1266f4b7383c46 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Thu, 15 Jan 2026 09:51:56 +0800 Subject: [PATCH] fix: prevent Microsoft Teams from being misdetected as Edge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #313 Change browser process detection from pgrep -f (full command line match) to pgrep -x (exact process name match) to prevent false positives. Microsoft Teams processes contain 'Microsoft' in their paths and may have Chromium-based components, which was causing them to be incorrectly identified as Microsoft Edge during clean operations. Changes: - Chrome detection: pgrep -f → pgrep -x - Edge detection: pgrep -f → pgrep -x - Edge updater detection: pgrep -f → pgrep -x This approach is consistent with Firefox detection and prevents Apps like Microsoft Teams, Microsoft Office, or other Microsoft products from triggering false Edge detection. All existing tests pass (9/9 in clean_browser_versions.bats). --- lib/clean/user.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/clean/user.sh b/lib/clean/user.sh index 014b1b6..82d2b6d 100644 --- a/lib/clean/user.sh +++ b/lib/clean/user.sh @@ -84,8 +84,8 @@ clean_chrome_old_versions() { "$HOME/Applications/Google Chrome.app" ) - # Use -f to match Chrome Helper processes as well - if pgrep -f "Google Chrome" > /dev/null 2>&1; then + # Match the exact Chrome process name to avoid false positives + if pgrep -x "Google Chrome" > /dev/null 2>&1; then echo -e " ${YELLOW}${ICON_WARNING}${NC} Google Chrome running · old versions cleanup skipped" return 0 fi @@ -164,8 +164,8 @@ clean_edge_old_versions() { "$HOME/Applications/Microsoft Edge.app" ) - # Use -f to match Edge Helper processes as well - if pgrep -f "Microsoft Edge" > /dev/null 2>&1; then + # Match the exact Edge process name to avoid false positives (e.g., Microsoft Teams) + if pgrep -x "Microsoft Edge" > /dev/null 2>&1; then echo -e " ${YELLOW}${ICON_WARNING}${NC} Microsoft Edge running · old versions cleanup skipped" return 0 fi @@ -242,7 +242,7 @@ clean_edge_updater_old_versions() { local updater_dir="$HOME/Library/Application Support/Microsoft/EdgeUpdater/apps/msedge-stable" [[ -d "$updater_dir" ]] || return 0 - if pgrep -f "Microsoft Edge" > /dev/null 2>&1; then + if pgrep -x "Microsoft Edge" > /dev/null 2>&1; then echo -e " ${YELLOW}${ICON_WARNING}${NC} Microsoft Edge running · updater cleanup skipped" return 0 fi