fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
534 stars 99 forks source link

Running osascript can cause errors #4732

Open dscorbett opened 1 month ago

dscorbett commented 1 month ago

Observed behavior

Rarely, in the default Terminal on macOS, get_apple_terminal_bg_color raises an error because the osascript process returns an exit code of 1.

Expected behavior

Because Font Bakery only runs osascript to determine the proper output theme, which is not very important, it should use a fallback theme instead of failing the build when osascript errors.

Resources and steps needed to reproduce

It is hard to reproduce this in Font Bakery, but the following script shows that it can fail in general. It usually terminates in a few minutes.

while :
do
    for i in {1..10}
    do
        osascript -e 'tell application "Terminal"' -e '    get background color of selected tab of window 1' -e 'end tell' >/dev/null &
    done
    osascript -e 'tell application "Terminal"' -e '    get background color of selected tab of window 1' -e 'end tell' >/dev/null
    if [ $? -ne 0 ]; then break; fi
done

The error message is

36:52: execution error: Terminal got an error: Can’t get selected tab of window 1. (-1728)