From 7eed5d1db4fe0abca166e3ab2f57576fd3e01075 Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Tue, 18 Mar 2025 09:44:09 +1300 Subject: [PATCH] Everything else `+set` => `:-` --- target/scripts/helpers/error.sh | 2 +- target/scripts/helpers/log.sh | 6 +++--- target/scripts/helpers/utils.sh | 4 ++-- test/helper/common.bash | 2 +- test/helper/setup.bash | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/scripts/helpers/error.sh b/target/scripts/helpers/error.sh index 3af736df..bac3630e 100644 --- a/target/scripts/helpers/error.sh +++ b/target/scripts/helpers/error.sh @@ -1,7 +1,7 @@ #!/bin/bash function _exit_with_error() { - if [[ -n ${1+set} ]]; then + if [[ -n ${1:-} ]]; then _log 'error' "${1}" else _log 'error' "Call to '_exit_with_error' is missing a message to log" diff --git a/target/scripts/helpers/log.sh b/target/scripts/helpers/log.sh index d98f96a8..e4ba5ea6 100644 --- a/target/scripts/helpers/log.sh +++ b/target/scripts/helpers/log.sh @@ -43,12 +43,12 @@ RESET=$(echo -ne '\e[0m') # message is logged. Likewise when the second argument # is missing. Both failures will return with exit code '1'. function _log() { - if [[ -z ${1+set} ]]; then + if [[ -z ${1:-} ]]; then _log 'error' "Call to '_log' is missing a valid log level" return 1 fi - if [[ -z ${2+set} ]]; then + if [[ -z ${2:-} ]]; then _log 'error' "Call to '_log' is missing a message to log" return 1 fi @@ -116,7 +116,7 @@ function _log() { # variables file. If this does not yield a value either, # use the default log level. function _get_log_level_or_default() { - if [[ -n ${LOG_LEVEL+set} ]]; then + if [[ -n ${LOG_LEVEL:-} ]]; then echo "${LOG_LEVEL}" elif [[ -e /etc/dms-settings ]] && grep -q -E "^LOG_LEVEL='[a-z]+'" /etc/dms-settings; then grep '^LOG_LEVEL=' /etc/dms-settings | cut -d "'" -f 2 diff --git a/target/scripts/helpers/utils.sh b/target/scripts/helpers/utils.sh index 90fd8f9b..468a4e74 100644 --- a/target/scripts/helpers/utils.sh +++ b/target/scripts/helpers/utils.sh @@ -131,9 +131,9 @@ function _reload_postfix() { # 1. No first and second argument is supplied # 2. The second argument is a path to a file that does not exist function _replace_by_env_in_file() { - if [[ -z ${1+set} ]]; then + if [[ -z ${1:-} ]]; then _dms_panic__invalid_value 'first argument unset' 'utils.sh:_replace_by_env_in_file' - elif [[ -z ${2+set} ]]; then + elif [[ -z ${2:-} ]]; then _dms_panic__invalid_value 'second argument unset' 'utils.sh:_replace_by_env_in_file' elif [[ ! -f ${2} ]]; then _dms_panic__invalid_value "file '${2}' does not exist" 'utils.sh:_replace_by_env_in_file' diff --git a/test/helper/common.bash b/test/helper/common.bash index 35f41283..4e4ddf6a 100644 --- a/test/helper/common.bash +++ b/test/helper/common.bash @@ -56,7 +56,7 @@ function __handle_container_name() { if [[ -n ${1:-} ]] && [[ ${1:-} =~ ^dms-test_ ]]; then printf '%s' "${1}" return 0 - elif [[ -n ${CONTAINER_NAME+set} ]]; then + elif [[ -n ${CONTAINER_NAME:-} ]]; then printf '%s' "${CONTAINER_NAME}" return 0 else diff --git a/test/helper/setup.bash b/test/helper/setup.bash index ed2e4e32..3393d640 100644 --- a/test/helper/setup.bash +++ b/test/helper/setup.bash @@ -17,7 +17,7 @@ # This function is internal and should not be used in tests. function __initialize_variables() { function __check_if_set() { - if [[ ${!1+set} != 'set' ]]; then + if [[ -z ${1:-} ]]; then echo "ERROR: (helper/setup.sh) '${1:?No variable name given to __check_if_set}' is not set" >&2 exit 1 fi