4 ms·
retry() { local n=$1 shift for i in $(seq $n); do "$@" done } This is not a retry function, it's a "run a function 5 times" function. R
by aljarry 2y ago
retry() {
local n=$1
shift
for i in $(seq $n); do
"$@"
done
}
This is not a retry function, it's a "run a function 5 times" function. Retry would check the outcome of the operation, and only for failed cases would run it additional times. It is definitely possible in bash, it's just a few more lines.