From 2bbab739dc8fa868a42c9210d3404feb546d584f Mon Sep 17 00:00:00 2001 From: Neville Kadwa Date: Tue, 16 Jan 2018 15:03:37 -0500 Subject: [PATCH] add environment variable for retry attempt number; fix #9 --- retry | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retry b/retry index 321a394..402c517 100755 --- a/retry +++ b/retry @@ -44,13 +44,14 @@ retry() P="$1" for param in "${@:2}"; do P="$P '$param'"; done #TODO: replace single quotes in each arg with '"'"' ? + export RETRY_ATTEMPT=$attempts bash -c "$P" return_code=$? #__log_out "Process returned $return_code on attempt $attempts" if [ $return_code -eq 127 ]; then # command not found exit $return_code - else + elif [ $return_code -ne 0 ]; then attempts=$[$attempts +1] fi done