Мое воображаемое решение:
run_til_failure() {
local didBreak=0
for task in [TASKS]; do
process "$task" || { didBreak=1; break; }
commit "$task"
done
local loopExit=$?
if (( loopExit )); then return $loopExit; fi
return $didBreak
}
Вы можете сделать что-нибудь вроде
failed=false
for task in "${tasks[@]}"; do
if ! process "$task"; then
failed=true
break
fi
commit "$task"
done
if "$failed"; then
echo "Failed something" >&2
fi