2 # shellcheck disable=SC2016
5 # Execute in a subshell to prevent local variable override during recursion
7 local total_attempts=$1; shift
10 echo -e "\n[wait_for] Waiting for cmd to return success: ${cmdstr}"
11 # shellcheck disable=SC2034
12 for attempt in $(seq "${total_attempts}"); do
13 echo "[wait_for] Attempt ${attempt}/${total_attempts%.*} for: ${cmdstr}"
14 # shellcheck disable=SC2015
15 eval "${cmdstr}" && echo "[wait_for] OK: ${cmdstr}" && return 0 || true
18 echo "[wait_for] ERROR: Failed after max attempts: ${cmdstr}"