Restore function "with_default_retries"

1) Previous commit removed a shell function by mistake, that is being
referenced by "clone-source". Restore this function.

2) Make sure "with_retries" works correctly when "set -e" is in effect

Story: 2010226
Task: 48064

TESTS
==========================
Run "clone-source" and make sure it works

Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
Change-Id: I1bbf4bf041305860d2c8db83f5130f424084255c
This commit is contained in:
Davlet Panech 2023-05-25 16:15:47 -04:00
parent 65b3abbae9
commit 2ae368cc7f

View File

@ -66,13 +66,13 @@ function with_retries {
local rc=0
while :; do
let attempt++
let ++attempt
echo "Running: ${cmd} $@" >&2
${to_cmd} ${cmd} "$@"
rc=$?
if [ $rc -eq 0 ]; then
if ${to_cmd} ${cmd} "$@" ; then
return 0
else
rc=$?
fi
if [ $rc -eq 124 ]; then
@ -92,5 +92,13 @@ function with_retries {
return 1
fi
done
# unreachable
return 1
}
function with_default_retries {
local cmd=$1
shift 1
with_retries -d "${RETRY_INTERVAL_SEC:-1}" "${RETRIES:-1}" "${cmd}" "$@"
}