function retry_backoff {local m=${ATTEMPTS:-5};local t=${TIMEOUT:-1};local a=0;local e=1;while (($a < $m));do "$@";e=$?;if (($e == 0)); then break;fi;echo "Failure! Retrying in $t.." 1>&2;sleep $t;((a++));t=$((t*2));done;if (($e != 0));then echo "Max attempts reached!" 1>&2;fi;return $e; }
retry_backoff $YOUR_COMMAND # default of 5 retries, starting with 1 second timeout