You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bashunit learn generates starter files that are not valid bash #1256
bashunit learn writes a starter file for each lesson, and 7 of the 10 templates do not parse. A function body of only comments is a syntax error in bash, and the templates are full of them — 28 comment-only bodies across the lessons:
functiontear_down() {
# TODO: Clean up test files
}
So a learner who runs the lesson to generate the file, fills in one TODO and runs again gets:
challenge_test.sh: line 72: syntax error near unexpected token `}'
✗ Error: Source
That says nothing about the lesson, and the invalid file came from bashunit itself. It is the first thing a newcomer to the tool sees.
The fix needs two halves
Adding a : no-op to each body makes the file parse — and on its own that is worse, because an untouched template then passes the lesson:
template
run
result
comments only (today)
plain
syntax error
valid with :
plain
exit 0 — lesson completed with no work done
valid with :
--fail-on-risky
exit 1
actually solved
--fail-on-risky
exit 0
bashunit::learn::run_lesson_test runs "$BASHUNIT_ROOT_DIR/bashunit" "$test_file" --simple and treats exit 0 as success. A test with no assertions is risky, and risky exits 0 by default.
So: make the templates parse, and run the lesson's verification with --fail-on-risky. The learner then sees "risky: no assertions" — which is the actual state of their work — instead of a bash syntax error, and cannot complete a lesson without writing an assertion.
Verified
All 16 assertions the lessons teach exist in src/assert/, so the taught API itself is accurate; this is about the generated files.
Activity
Chemaclass commentedon Aug 14, 2026
Done in #1257 (merged).