fix(grading): stop autograder from silently crashing under bash 5#5
Merged
Conversation
`((score += l1))`-style compound assignment is a false command in bash whenever the resulting value is 0 -- exit status 1 even though the assignment succeeded. Under `set -e` (used by every autograder here), that silently kills the script mid-run on GitHub Actions' Ubuntu runners (bash 5), while working fine locally on macOS (bash 3.2, which does not enforce this). Any student whose running score hits exactly 0 at a checkpoint -- most commonly an early, mostly-empty submission -- got a grading run that failed with a bare "exit code 1" and no score.json update, not a real 0 score. Reproduced locally with bash 5 against an empty scaffold; confirmed exit 0 after the fix, and re-verified real solution runs still score correctly. Fix: rewrite every `((var += expr))`/`((var -= expr))` as `var=$((var + expr))`, and guard bare check_*() calls that can legitimately return non-zero (a warn/fail signal, not a script error) with `|| true` so `set -e` does not treat them as fatal. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
((var += expr))reports a failing exit status whenever the resulting arithmetic value is0-- a well-known bash gotcha. Combined withset -euo pipefail, the grader silently dies mid-run the moment a student's running score hits exactly 0 at a checkpoint (e.g. a mostly-empty early submission).check_*()helper calls (which legitimatelyreturn 1to signal warn/fail, not a script error) with|| trueso they don't tripset -eeither.Test plan
bash -n .hyf/test.sh🤖 Generated with Claude Code