Everything else `+set` => `:-`
This commit is contained in:
parent
9c39b82887
commit
7eed5d1db4
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue