From 0faf02ae5ede5870e24c6248818e849622df6c95 Mon Sep 17 00:00:00 2001 From: Fred Hamster Date: Mon, 16 Dec 2024 20:18:21 -0500 Subject: [PATCH] wrapping the "okay but show output" results better --- scripts/core/variables.sh | 5 +++++ .../fred/scripts/jobby/archie_grabber_uva.sh | 3 ++- scripts/testing/squelch_unless_error.sh | 15 +++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index 3304ba79..8a7a5fae 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -75,6 +75,11 @@ if [ -z "$CORE_VARIABLES_LOADED" ]; then ############## # start with some simpler things. + + # special protocol for return values--if we see this, it means we should still show + # the standard output and there was no actual error. implemented in + # squelch_unless_error. + define_yeti_variable MAGICAL_FEISTY_MEOW_OKAY_RETURN_VALUE=242 #hmmm: this needs to come from some configuration item. especially for installs. define_yeti_variable DEFAULT_FEISTYMEOW_ORG_DIR=/opt/feistymeow.org diff --git a/scripts/customize/fred/scripts/jobby/archie_grabber_uva.sh b/scripts/customize/fred/scripts/jobby/archie_grabber_uva.sh index ad824447..9703adc1 100644 --- a/scripts/customize/fred/scripts/jobby/archie_grabber_uva.sh +++ b/scripts/customize/fred/scripts/jobby/archie_grabber_uva.sh @@ -43,7 +43,8 @@ popd &>/dev/null popd &>/dev/null #nope. we do not want to signal an error when we have already caught it. #exit $retval -exit 0 +# special exit value means "show the output but there was no error". +exit $MAGICAL_FEISTY_MEOW_OKAY_RETURN_VALUE ' > $ARCHIVE_SNAGGER_COMMAND #s diff --git a/scripts/testing/squelch_unless_error.sh b/scripts/testing/squelch_unless_error.sh index 12f9bb86..f9fdf01b 100644 --- a/scripts/testing/squelch_unless_error.sh +++ b/scripts/testing/squelch_unless_error.sh @@ -16,10 +16,17 @@ eval "${@}" >"$newout" 2>"$newerr" retval=$? if [ $retval != 0 ]; then - # there was an error during the execution of the command. - cat "$newout" - cat "$newerr" >&2 - echo "An error was returned during execution of: ${@}" >&2 + if [ $retval -eq $MAGICAL_FEISTY_MEOW_OKAY_RETURN_VALUE ]; then + # special standard here means that we will still show the output, but there was no actual error. + cat "$newout" + # reset to a non-error for our special case. + retval=0 + else + # there was an actual error during the execution of the command. + cat "$newout" + cat "$newerr" >&2 + echo "An error was returned during execution of: ${@}" >&2 + fi fi # clean up. -- 2.34.1