Running ShellCheck on retry generates the following list of warnings. This PR fixes the warnings. It also adds tests, a Bash script that runs three basic functionality tests on retry.
In retry line 11:
sleep_time=`awk "BEGIN {t = $min_sleep * $(( (1<<($attempts -1)) )); print (t > $max_sleep ? $max_sleep : t)}"`
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^-------^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
Did you mean:
sleep_time=$(awk "BEGIN {t = $min_sleep * $(( (1<<($attempts -1)) )); print (t > $max_sleep ? $max_sleep : t)}")
In retry line 43:
sleep $sleep_time
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
sleep "$sleep_time"
In retry line 57:
attempts=$[$attempts +1]
^-------------^ SC2007 (style): Use $((..)) instead of deprecated $[..]
In retry line 61:
if [ $attempts -gt $max_tries ]; then
^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [ "$attempts" -gt "$max_tries" ]; then
In retry line 64:
eval $fail_script
^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
eval "$fail_script"
In retry line 74:
if [ "$BASH_SOURCE" == "$0" ]; then
^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
In retry line 78:
local retry=$(basename $0)
^---^ SC2155 (warning): Declare and assign separately to avoid masking return values.
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
local retry=$(basename "$0")
In retry line 112:
if [[ $? -ne 0 ]]; then
^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
For more information:
https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ...
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
Running ShellCheck on
retry
generates the following list of warnings. This PR fixes the warnings. It also addstests
, a Bash script that runs three basic functionality tests onretry
.