Check osascript output instead of exit status (#42951)

Capture osascript output into a variable and compare it to "true" when
checking if an app is running. Updated quit_application and
quit_and_track_application to use app_running=$(osascript ...) and [[
"$app_running" != "true" ]] rather than relying on the command's exit
status. This makes the running check more reliable across osascript
behaviors and avoids depending on its exit code.
This commit is contained in:
Allen Houchins 2026-04-03 08:48:58 -05:00 committed by GitHub
parent 06cb6f6044
commit 93d6e3cc43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -535,7 +535,9 @@ const quitApplicationFunc = `quit_application() {
local timeout_duration=10
# check if the application is running
if ! osascript -e "application id \"$bundle_id\" is running" 2>/dev/null; then
local app_running
app_running=$(osascript -e "application id \"$bundle_id\" is running" 2>/dev/null)
if [[ "$app_running" != "true" ]]; then
return
fi
@ -576,7 +578,9 @@ const quitAndTrackApplicationFunc = `quit_and_track_application() {
local timeout_duration=10
# check if the application is running
if ! osascript -e "application id \"$bundle_id\" is running" 2>/dev/null; then
local app_running
app_running=$(osascript -e "application id \"$bundle_id\" is running" 2>/dev/null)
if [[ "$app_running" != "true" ]]; then
eval "export $var_name=0"
return
fi