diff --git a/cronic b/cronic index b26d786..34f5294 100755 --- a/cronic +++ b/cronic @@ -14,6 +14,8 @@ # --duplicate-stderr options, which may be given in any order. # The options and the treatment of execution traces are documented in function # `cronic_help`; run `cronic --help`. +# This script runs under bash 3.2, which is /bin/bash on macOS, so it uses a +# feature of a later bash only after checking the version. # Exit if a command exits with a non-zero status, and treat unset variables # as an error. @@ -200,8 +202,8 @@ cronic_pattern=$(cronic_trace_pattern) if [ -n "$cronic_pattern" ] && grep -q "$cronic_pattern" "$cronic_trace"; then # `|| true` because `grep -v` exits with status 1 when it selects no lines, # which happens whenever stderr consists only of trace lines. Without it, - # `set -e` would abort the script here, before it produces its report, - # exits with the wrapped command's status, and removes its temporary files. + # `set -e` would abort the script here, before it produces its report, and + # it would exit with status 1 rather than with the wrapped command's status. grep -v "$cronic_pattern" "$cronic_trace" > "$cronic_err" || true else cronic_err=$cronic_trace diff --git a/tests/cronic-test/cronic-test.sh b/tests/cronic-test/cronic-test.sh index 7b62509..2b91289 100755 --- a/tests/cronic-test/cronic-test.sh +++ b/tests/cronic-test/cronic-test.sh @@ -6,9 +6,10 @@ # # `cronic` filters trace lines out of stderr with `grep -v`, which exits with # status 1 when it selects no lines. `cronic` runs under `set -e`, so an -# unguarded `grep -v` aborted the script at that point: no report was printed, -# the exit status was grep's 1 rather than the wrapped command's, and all of -# the temporary files under /tmp were left behind. +# unguarded `grep -v` would abort the script at that point: no report would be +# printed, and the exit status would be grep's 1 rather than the wrapped +# command's. (The temporary files would still be removed, by `cronic`'s EXIT +# trap, so the left-behind-files check in `check` does not detect that bug.) set -eu