1 2 3 4 5 6 7 8 9 10 11 12 13 14
retry() { if eval "$@"; then return 0 fi for i in 2 1; do sleep 3s echo "Retrying $i..." if eval "$@"; then return 0 fi done return 1 }