Retry a Bash command with timeout

How to retry a bash command until its status is ok or until a timeout is reached?

My best shot (I'm looking for something simpler):

NEXT_WAIT_TIME=0
COMMAND_STATUS=1
until [ $COMMAND_STATUS -eq 0 || $NEXT_WAIT_TIME -eq 4 ]; do
  command
  COMMAND_STATUS=$?
  sleep $NEXT_WAIT_TIME
  let NEXT_WAIT_TIME=NEXT_WAIT_TIME+1
done

Answers


You can simplify things a bit by putting command right in the test and doing increments a bit differently. Otherwise the script looks fine:

NEXT_WAIT_TIME=0
until command || [ $NEXT_WAIT_TIME -eq 4 ]; do
   sleep $(( NEXT_WAIT_TIME++ ))
done

Need Your Help

NSUserNotificationCenter dismiss notification

cocoa nsnotificationcenter osx-mountain-lion nsusernotification

I'm trying to use the new Mountain Lion NSUserNotificationCenter for my application (which isn't too hard actually). Posting notifications works like a charm via

SVG Path Element

svg

I know what "c0.88,0.88,2.75,1.82,5.25,1.75" means. But I don't know what "c8.62-0.25,20-2.12,29.5-4.25" means, especially the '-' symbol in it. Thank you in advance.