Project: A Test Report Script
Options with getopts, input validation, a summary and a CI-friendly exit status.
This script turns the test-bench CSV into a summary for one board. It shows the structure of a real command-line tool: option parsing, a usage message, input checks, processing, and an exit status that CI systems understand.
The script
getopts "b:vh" parses -b board (with a value), -v and -h; OPTARG holds the value.
shift $(( OPTIND - 1 )) removes the parsed options, leaving the file name as $1.
Errors and usage go to standard error (>&2) with distinct exit codes (2 for usage, 1 for unreadable input).
The final (( fail == 0 )) makes the script exit with status 0 only if every test passed.
Where scripts like this run
Ending every script with exit 0 Exit with a status that reflects the result
Callers — people, other scripts, CI — rely on the exit status to know whether it worked.
Why do scripts print errors to standard error?
So the normal output can be piped or saved without error messages mixed in, while errors still appear on the terminal.