I have this simple run-handler:
on run {}
set caffeinatePid to do shell script "caffeinate -d > /dev/null 2>&1 & echo $!"
set noLoops to 157
do shell script "/opt/local/bin/brightness 0.05"
start()
do shell script "kill " & caffeinatePid
do shell script "/Library/Python/3.9/bin/pb push done!"
end run
start() does all the heavy lifting. It exits cleanly and I have stepped through the following two lines, and when I do I see that after the last line the script starts over with the set caffeinatePid-line. Wot!?!?
I have executed this script for years without issues but (maybe) after upgrading to Tahoe it started to behave like this. I have ran it from Script Editor, Script Debugger and osascript, and it behaves the same everywhere.