From cb5ab38b093b7d42f7e6e34a033eb3a537950262 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Thu, 17 Feb 2022 11:40:06 +0300 Subject: [PATCH] Run osascript with retry (#5090) --- images/macos/provision/core/open_windows_check.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/images/macos/provision/core/open_windows_check.sh b/images/macos/provision/core/open_windows_check.sh index 1392e0654..002c254bd 100644 --- a/images/macos/provision/core/open_windows_check.sh +++ b/images/macos/provision/core/open_windows_check.sh @@ -1,6 +1,16 @@ #!/bin/bash -e -o pipefail -openwindows=$(osascript -e 'tell application "System Events" to get every window of (every process whose class of windows contains window)') +retry=10 +while [ $retry -gt 0 ]; do + openwindows=$(osascript -e 'tell application "System Events" to get every window of (every process whose class of windows contains window)') && break + + retry=$((retry-1)) + if [ $retry -eq 0 ]; then + echo "No retry attempts left" + exit 1 + fi + sleep 30 +done IFS=',' read -r -a windowslist <<< "$openwindows" if [ -n "${openwindows}" ]; then