0
0
mirror of https://github.com/thegeeklab/retry.git synced 2024-11-28 07:30:36 +00:00

add environment variable for retry attempt number; fix #9

This commit is contained in:
Neville Kadwa 2018-01-16 15:03:37 -05:00
parent 3b9de02bd8
commit 2bbab739dc

3
retry
View File

@ -44,13 +44,14 @@ retry()
P="$1" P="$1"
for param in "${@:2}"; do P="$P '$param'"; done for param in "${@:2}"; do P="$P '$param'"; done
#TODO: replace single quotes in each arg with '"'"' ? #TODO: replace single quotes in each arg with '"'"' ?
export RETRY_ATTEMPT=$attempts
bash -c "$P" bash -c "$P"
return_code=$? return_code=$?
#__log_out "Process returned $return_code on attempt $attempts" #__log_out "Process returned $return_code on attempt $attempts"
if [ $return_code -eq 127 ]; then if [ $return_code -eq 127 ]; then
# command not found # command not found
exit $return_code exit $return_code
else elif [ $return_code -ne 0 ]; then
attempts=$[$attempts +1] attempts=$[$attempts +1]
fi fi
done done