I've already asked this question in the UNIx exchange but I was told to ask here also about AppleScripts if the standard shell does not work.
I require a script that will open an application. Wait for it to exit, if the application exited gracefully (I.E: did not crash) relaunch it. Otherwise, keep the crash report open and exit the script. I'd like this script to run until I quit it manually.
So far the following has been suggested:
while open -W /path/to/application.app do : done
But this opens the application and then either on crash or exit will automatically run it again. I assume this is because open regardless of waiting or not will terminate with a normal 0 exit code. Unless of course open crashes but in this case it will not.
Any assistance with this is appreciated.