Browse files

binary-backoff: show exit status on failure

  • Loading branch information...
1 parent a144029 commit 52febba80174d5053cbb35eb0ca04f16d54425ac @janmoesen committed Jul 25, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 .bash/commands
View
10 .bash/commands
@@ -965,7 +965,11 @@ function binary-backoff {
local num_tries=0;
while [ -z "$MAX_BB_TRIES" ] || [ $num_tries -lt $MAX_BB_TRIES ]; do
# If successful, stop immediately.
- "$@" && return $?;
+ "$@" && return;
+
+ # Remember the non-zero exit status.
+ exit_status=$?;
+ exit_msg="Exit status: $exit_status.";
# Check if have reached the maximum number of tries.
let num_tries++;
@@ -983,14 +987,14 @@ function binary-backoff {
[ $num_seconds_left -eq 1 ] \
&& local time_unit=second \
|| local time_unit=seconds;
- echo "${move_up}${clear_line}Waiting for $num_seconds_left $time_unit after $num_tries tries…" 1>&2;
+ echo "${move_up}${clear_line}${exit_msg} Waiting for $num_seconds_left $time_unit after $num_tries tries…" 1>&2;
sleep 1;
let num_seconds_left--;
done;
[ $delay -eq 1 ] \
&& local time_unit=second \
|| local time_unit=seconds;
- echo "${move_up}${clear_line}Waited for $delay $time_unit. Retrying." 1>&2;
+ echo "${move_up}${clear_line}${exit_msg} Waited for $delay $time_unit. Retrying" 1>&2;
# Double the delay, but cap it at MAX_BB_DELAY.
let delay*=2;

0 comments on commit 52febba

Please sign in to comment.