## report.bash: how pave says what happened. ## ## Every run keeps a tally file: one 'c' per change and one 'f' per failure, ## appended by whichever shell (or subshell) observed it. ## A file rather than a variable, because chains and goal files run in subshells, ## and their counts have to survive back to the runner. ## changed reports one act of convergence. ## Goal files may call it too, when converging by hand with plain commands. ## ## - @param $1... description of the change. ## - @stdout the report line. changed() { printf 'pave: changed: %s\n' "$*" printf c >>"$_PAVE_TALLY" } ## _pave_error explains why something can't be converged. ## It's a reason, not a failure record: whoever then fails records that, with a location. ## ## - @param $1... the explanation. ## - @stderr the explanation. _pave_error() { >&2 printf 'pave: error: %s\n' "$*" } ## _pave_fail records one failure. ## ## - @param $1... what failed, and where. ## - @stderr the failure line. _pave_fail() { >&2 printf 'pave: FAIL: %s\n' "$*" printf f >>"$_PAVE_TALLY" } ## _pave_count prints how many of one tally letter have been recorded. ## ## - @param $1 the letter: c or f. ## - @stdout the count. _pave_count() { local t='' IFS= read -r t <"$_PAVE_TALLY" || : t=${t//[^$1]/} printf '%d' "${#t}" }