diff options
author | Bryan Drewery <bryan@shatow.net> | 2022-05-28 02:43:35 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2022-05-28 02:51:38 +0300 |
commit | 8170f398de45251a62fd7b662f294ce9c4a289c9 (patch) | |
tree | 959c60822a199deb9f044701b4c2298e37765487 /src | |
parent | 10867ecb1ec078b5979e0bb8d4f524397e085932 (diff) |
Tweak error spam on exit to avoid false-positives.
Issue #985
Diffstat (limited to 'src')
-rwxr-xr-x | src/share/poudriere/common.sh | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index fe834720..27286c70 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -1285,7 +1285,11 @@ exit_handler() { *x*) ;; *) local -; set +x ;; esac - + # Don't spam errors with 'set +e; exit >0'. + case "$-" in + *e*) ;; + *) ERROR_VERBOSE=0 ;; + esac # Ignore errors while cleaning up set +e ERRORS_ARE_FATAL=0 @@ -1323,9 +1327,16 @@ exit_handler() { cd "${MASTER_DATADIR}" fi fi - if [ "${exit_status}" -ne 0 ] && [ "${CRASHED:-0}" -eq 0 ]; then + + case "${exit_status}" in + 0|${EX_USAGE}) + : ${ERROR_VERBOSE:=0} ;; + *) : ${ERROR_VERBOSE:=1} ;; + esac + if [ "${ERROR_VERBOSE}" -eq 1 ] && [ "${CRASHED:-0}" -eq 0 ]; then echo "[ERROR] Unhandled error!" >&2 fi + if was_a_jail_run; then # Don't use jail for any caching in cleanup SHASH_VAR_PATH="${SHASH_VAR_PATH_DEFAULT}" @@ -1364,7 +1375,7 @@ exit_handler() { if [ -n "${POUDRIERE_TMPDIR-}" ]; then rm -rf "${POUDRIERE_TMPDIR}" >/dev/null 2>&1 || : fi - if [ "${exit_status}" -ne 0 ]; then + if [ "${ERROR_VERBOSE}" -eq 1 ]; then echo "Exiting with status ${exit_status}" >&2 || : fi } |