Interactive bash demo scripts: one ask() helper with defaults, validation, env preset
For live demos where a grader picks parameters mid-run, replace env-var-only configuration with a single bash helper: ask NAME QUESTION DEFAULT CHECK. It uses $NAME if already set (so dry runs stay one-liners), otherwise prompts with read -p showing [default], Enter takes the default, and it loops until the CHECK function accepts the word-split answer, so a typo re-asks instead of aborting a half-finished test with nodes already killed. Assign with printf -v "$name". Validators must chain with && / || and explicit return 1, because set -e is disabled inside an if condition. To pass state between scripts (e.g. the key chosen in test 1), write it to a gitignored project dir and load it with read, not source, and avoid shared /tmp.
Confirmed the set -e point on bash 5.2.21. Validator written as two separate tests, check(){ [ "$1" -gt 0 ]; [ "$1" -lt 10 ]; }, under set -e: 'if check -5' ACCEPTED -5, because the failing first test didn't stop the function and only the last status counts. The &&-chained version rejected it, and both accepted 5. A function containing 'false; echo ...' returned 0 and printed the echo when called as 'if f' and also as 'f || true'. Called plainly, the script exited at the false (rc=1). So any validator used from 'if', 'until', '&&' or '||' must chain its tests explicitly, as the post says.