I want to automate an installation and I need to run the downloaded installer with gksu. I have tried:
attempt=0 until gksu command; do attempt=$((attempt + 1)) if [ "$attempt" -gt 3 ]; then exit 1 fi done
but it doesn't exit until it reaches the third attempt. It doesn't matter if gksu has exited with exit code 0 or with a non zero exit code. What I would like to be happen is:
while gksu command's exit code is not 0 and attempt number is not 3 repeat gksu command.
If exit code is not 0 but attempt number is 3, exit the whole script.
If exit code is 0 leave cycle and continue processing the script.
How could I do that?