.mise/tasks/retry
.mise/tasks/retryBrowse 1970 files
215 tokens
669 bytes
Token encoding: o200k_base
Snapshot 21a254f
← Back to SKILL.md
1#!/usr/bin/env bash2#MISE description="Retry a command with exponential backoff"3#USAGE flag "--attempts <attempts>" help="Number of attempts" default="3"4#USAGE arg "<command>" var=#true help="Command to run" double_dash="automatic"5 6set -euo pipefail7 8attempts="${usage_attempts?}"9delay=110 11eval "cmd=($usage_command)"12 13if [[ ${#cmd[@]} -eq 0 ]]; then14 echo "Error: command required" >&215 exit 116fi17 18for ((i = 1; i <= attempts; i++)); do19 if "${cmd[@]}"; then20 exit 021 fi22 23 if [[ $i -lt $attempts ]]; then24 echo "failed, retrying..." >&225 sleep "$delay"26 delay=$((delay * 2))27 fi28done29 30echo "continued to fail after ${attempts} attempts" >&231exit 132