From 805085ff455cdcc868bf44f8b8485808475dbd38 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Sun, 22 Jan 2023 15:56:25 +0100 Subject: [PATCH] armbian-next: `logging`: validate where not already in a logging section when trying to start a new one - with a small exception for 'entrypoint' ;-) --- lib/functions/logging/section-logging.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/functions/logging/section-logging.sh b/lib/functions/logging/section-logging.sh index ea8030a014..edf94c9378 100644 --- a/lib/functions/logging/section-logging.sh +++ b/lib/functions/logging/section-logging.sh @@ -1,4 +1,10 @@ function start_logging_section() { + # Sanity check: if this is called, but CURRENT_LOGGING_SECTION is not empty, then something is wrong. + if [[ -n "${CURRENT_LOGGING_SECTION}" && "${CURRENT_LOGGING_SECTION}" != "entrypoint" ]]; then + exit_with_error "ERROR: start_logging_section() called, but CURRENT_LOGGING_SECTION is not empty: current: '${CURRENT_LOGGING_SECTION}' trying to enter '${LOG_SECTION}'" + return 1 + fi + declare -g logging_section_counter=$((logging_section_counter + 1)) # increment counter, used in filename declare -g CURRENT_LOGGING_COUNTER CURRENT_LOGGING_COUNTER="$(printf "%03d" "$logging_section_counter")"