Reputation: 85
I'm trying to write a little bash script that launch a wine .exe file (Photoshop). During the launch, if there is a boot error, the message "Assertion failed" is displayed.
The concept would be:
wine64 "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe"
2>&1 | grep -i Assertion
pipefail
, and try to relaunch photoshop
Looping this till it boots.I tried to write a little script that is obviously wrong. How to make it works?
#!/bin/sh
set -euxo pipefail
wine64 "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe" 2>&1 | grep -i -L Assertion
if [ Assertion failed ]
then
wine64 "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe" 2>&1 | grep -i -L Assertion
fi
Upvotes: 0
Views: 58
Reputation: 123610
One way would be:
while grep -q Assertion < <(wine64 ... 2>&1)
do
pkill wine64
done
grep -q
will immediately exit with success when Assertion
is found, and since the input is from a process substitution, it will then not wait for wine64
to exit. This causes the loop to be entered and Wine to be restarted.
If the program exits without grep
finding Assertion
, then grep
exits with failure causing the loop to stop.
Upvotes: 1