V8.13.048.2025.10.06
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m24s
🔐 Generating a Private Live ISO TRIXIE. / 🔐 Generating a Private Live ISO TRIXIE. (push) Successful in 51m2s

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-10-07 00:08:40 +01:00
parent 1d711ea816
commit 7f678baa64
15 changed files with 249 additions and 55 deletions

View File

@@ -13,25 +13,38 @@
guard_sourcing
#######################################
# Unbound Variable Check and call Trap on ERR
# Unbound variable check and call trap on 'ERR'.
# Globals:
# ERR_UNBOUNDVAR
# Arguments:
# $1: VAR_NAME to check
# Returns:
# "${ERR_UNBOUNDVAR}"
# {ERR_UNBOUNDVAR: on failure
#######################################
check_var() {
declare var_name_to_check="$1"
if [[ -n "${!var_name_to_check+exists}" ]]; then
if [[ -n "${!var_name_to_check}" ]]; then
printf "\e[92m✅ Variable: '%s' exists and is NOT empty: '%s' \e[0m\n" "${var_name_to_check}" "${!var_name_to_check}"
else
printf "\e[92m✅ Variable: '%s' exists but is empty. \e[0m\n" "${var_name_to_check}"
fi
else
printf "\e[91m❌ Variable: '%s' is not declared. Exiting Script. \e[0m\n" "${var_name_to_check}" >&2
return "${ERR_UNBOUNDVAR}"
fi
}
### Prevents accidental 'unset -f'.
# shellcheck disable=SC2034
readonly -f check_var
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh