Hacker News new | ask | show | jobs
by aljarry 649 days 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.