srobo / robot-image-legacy

Build scripts for 2022 System Image
1 stars 0 forks source link

Verbose flag causes script to crash #2

Closed raccube closed 3 years ago

raccube commented 3 years ago

Using the -v flag causes the script to exit prematurely.

Expected behaviour

The script should continue to run with additional output displayed.

Steps to reproduce

Run ./build.sh --debug -v from the project root

sersorrel commented 3 years ago

this is because running ((VERBOSE++)) when $VERBOSE is 0 results in the exit status of the command being 1 (because the result of VERBOSE++ is the old value of VERBOSE, which is 0, and for arithmetic expressions, "If the value of the expression is non-zero, the return status is 0; otherwise the return status is 1."). the script sensibly includes set -e, so this causes it to exit.

isn't bash great?

a quick fix would be to do ((++VERBOSE)) instead.