I've looked all over for this and I'm not entirely sure how to do this.
I want to use a bash script to open an application using 'open' and then check the exit status of the application after it has finished.
As far as I am aware, open -W will exit with status 0 so long as the application did open, I'm not interested in this exit, I'm interested in the apps exit.
Currently I have the following script:
trap "echo manual abort; exit 1" 1 2 3 15;
while open -W /path/to/MyApp.app
echo "all is well"
done
exit 0
Which opens the app and then waits, if the exit status is 0 it will re-open the app again after closing. This is intended however, what I want is to be able to stop this script if the app itself didn't exit 0 rather than the command 'open' successfully exiting.
So in short:
Open MyApp.app
if MyApp.app (not open) crashes, stop the script, otherwise, re-open MyApp.app