Skip to content

Commit

Permalink
Merge pull request #5 from echeipesh/fix/loop-termination
Browse files Browse the repository at this point in the history
Fix loop termination
  • Loading branch information
echeipesh authored Oct 18, 2016
2 parents 7ab9207 + b5eed1c commit 7d27704
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/sbin/hdfs-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ function with_backoff() {
local attempt=0
local exitCode=0

while (( $attempt < $max_attempts ))
echo "Attempt $attempt of $max_attempts: $@"
do
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt of $max_attempts: $@"
set +e
"$@"
exitCode=$?
Expand All @@ -51,6 +50,8 @@ function with_backoff() {

if [[ $exitCode != 0 ]]; then
echo "Fail: $@ failed to complete after $max_attempts attempts" 1>&2
elif [[ $exitCode -gt 128 ]]; then
echo "Fail: $@ aborted by user" 1>&2
else
echo "Success: $@ completed after $attempt attempts" 1>&2
fi
Expand Down

0 comments on commit 7d27704

Please sign in to comment.