A recovery path can retry once after a failed first attempt. The script records how many attempts were needed and the final result.

Program

Play the script to choose the first status and see the recovery summary.

retry_recovery_plan.sh
#!/usr/bin/env bash

first_status=
if [ "$first_status" -ne 0 ]; then
    attempts=2
    result="recovered"
else
    attempts=1
    result="clean"
fi
echo "attempts=$attempts result=$result"
#!/usr/bin/env bash

first_status=
if [ "$first_status" -ne 0 ]; then
    attempts=2
    result="recovered"
else
    attempts=1
    result="clean"
fi
echo "attempts=$attempts result=$result"
retry A retry repeats work after a failed first attempt.
attempt count Recording attempts makes recovery behavior visible.
recovered A recovered result means the retry path made the workflow usable again.