Change 'function' style (#3364)

This commit is contained in:
Casper 2023-05-26 01:01:41 +02:00 committed by GitHub
parent cf74127f78
commit 37ca0f9ba9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 233 additions and 466 deletions

View file

@ -9,8 +9,7 @@
DOVECOT_USERDB_FILE=/etc/dovecot/userdb
DOVECOT_MASTERDB_FILE=/etc/dovecot/masterdb
function _create_accounts
{
function _create_accounts() {
: >/etc/postfix/vmailbox
: >"${DOVECOT_USERDB_FILE}"
@ -98,8 +97,7 @@ function _create_accounts
#
# see https://github.com/docker-mailserver/docker-mailserver/pull/2248#issuecomment-953313852
# for more details on this method
function _create_dovecot_alias_dummy_accounts
{
function _create_dovecot_alias_dummy_accounts() {
local DATABASE_VIRTUAL='/tmp/docker-mailserver/postfix-virtual.cf'
if [[ -f ${DATABASE_VIRTUAL} ]] && [[ ${ENABLE_QUOTAS} -eq 1 ]]; then
@ -157,8 +155,7 @@ function _create_dovecot_alias_dummy_accounts
# Support Dovecot master user: https://doc.dovecot.org/configuration_manual/authentication/master_users/
# Supporting LDAP users requires `auth_bind = yes` in `dovecot-ldap.conf.ext`, see docker-mailserver/docker-mailserver/pull/2535 for details
function _create_masters
{
function _create_masters() {
: >"${DOVECOT_MASTERDB_FILE}"
local DATABASE_DOVECOT_MASTERS='/tmp/docker-mailserver/dovecot-masters.cf'

View file

@ -6,8 +6,7 @@
# `setup-stack.sh:_setup_ldap` does not seem to configure for `/etc/postfix/virtual however.`
# NOTE: `accounts.sh` and `relay.sh:_populate_relayhost_map` also process on `postfix-virtual.cf`.
function _handle_postfix_virtual_config
{
function _handle_postfix_virtual_config() {
: >/etc/postfix/virtual
local DATABASE_VIRTUAL=/tmp/docker-mailserver/postfix-virtual.cf
@ -24,8 +23,7 @@ function _handle_postfix_virtual_config
fi
}
function _handle_postfix_regexp_config
{
function _handle_postfix_regexp_config() {
: >/etc/postfix/regexp
if [[ -f /tmp/docker-mailserver/postfix-regexp.cf ]]; then
@ -41,8 +39,7 @@ function _handle_postfix_regexp_config
fi
}
function _handle_postfix_aliases_config
{
function _handle_postfix_aliases_config() {
_log 'trace' 'Configuring root alias'
echo "root: ${POSTMASTER_ADDRESS}" >/etc/aliases
@ -55,8 +52,7 @@ function _handle_postfix_aliases_config
}
# Other scripts should call this method, rather than the ones above:
function _create_aliases
{
function _create_aliases() {
_handle_postfix_virtual_config
_handle_postfix_regexp_config
_handle_postfix_aliases_config

View file

@ -12,8 +12,7 @@ CHKSUM_FILE=/tmp/docker-mailserver-config-chksum
# Once container startup scripts complete, take a snapshot of
# the config state via storing a list of files content hashes.
function _prepare_for_change_detection
{
function _prepare_for_change_detection() {
_log 'debug' 'Setting up configuration checksum file'
_log 'trace' "Creating '${CHKSUM_FILE}'"
@ -22,8 +21,7 @@ function _prepare_for_change_detection
# Returns a list of changed files, each line is a value pair of:
# <SHA-512 content hash> <changed file path>
function _monitored_files_checksums
{
function _monitored_files_checksums() {
# If a wildcard path pattern (or an empty ENV) would yield an invalid path
# or no results, `shopt -s nullglob` prevents it from being added.
shopt -s nullglob

View file

@ -18,8 +18,7 @@ DATABASE_PASSWD="${DMS_CONFIG}/postfix-sasl-password.cf"
DATABASE_RELAY="${DMS_CONFIG}/postfix-relaymap.cf"
# Individual scripts with convenience methods to manage operations easier:
function _db_import_scripts
{
function _db_import_scripts() {
# This var is stripped by shellcheck from source paths below,
# like the shellcheck source-path above, it shouold match this scripts
# parent directory, with the rest of the relative path in the source lines:
@ -35,8 +34,7 @@ function _db_entry_add_or_append { _db_operation 'append' "${@}" ; } # Only us
function _db_entry_add_or_replace { _db_operation 'replace' "${@}" ; }
function _db_entry_remove { _db_operation 'remove' "${@}" ; }
function _db_operation
{
function _db_operation() {
local DB_ACTION=${1}
local DATABASE=${2}
local KEY=${3}
@ -126,8 +124,7 @@ function _db_operation
}
# Internal method for: _db_operation
function __db_list_already_contains_value
{
function __db_list_already_contains_value() {
# Avoids accidentally matching a substring (case-insensitive acceptable):
# 1. Extract the current value of the entry (`\1`),
# 2. Value list support: Split values into separate lines (`\n`+`g`) at V_DELIMITER,
@ -140,8 +137,7 @@ function __db_list_already_contains_value
# Internal method for: _db_operation + _db_has_entry_with_key
# References global vars `DATABASE_*`:
function __db_get_delimiter_for
{
function __db_get_delimiter_for() {
local DATABASE=${1}
case "${DATABASE}" in
@ -171,8 +167,7 @@ function __db_get_delimiter_for
# `\` can escape these (`/` exists in postfix-account.cf base64 encoded pw hash),
# But otherwise care should be taken with `\`, which should be forbidden for input here?
# NOTE: Presently only `.` is escaped with `\` via `_escape`.
function __escape_sed_replacement
{
function __escape_sed_replacement() {
# Matches any `/` or `&`, and escapes them with `\` (`\\\1`):
sed 's/\([/&]\)/\\\1/g' <<< "${ENTRY}"
}
@ -181,8 +176,7 @@ function __escape_sed_replacement
# Validation Methods
#
function _db_has_entry_with_key
{
function _db_has_entry_with_key() {
local KEY=${1}
local DATABASE=${2}
@ -202,8 +196,7 @@ function _db_has_entry_with_key
grep --quiet --no-messages --ignore-case "^${KEY_LOOKUP}" "${DATABASE}"
}
function _db_should_exist_with_content
{
function _db_should_exist_with_content() {
local DATABASE=${1}
[[ -f ${DATABASE} ]] || _exit_with_error "'${DATABASE}' does not exist"

View file

@ -3,8 +3,7 @@
# Manage DB writes for: DATABASE_QUOTA
# Logic to perform for requested operations handled here:
function _manage_dovecot_quota
{
function _manage_dovecot_quota() {
local ACTION=${1}
local MAIL_ACCOUNT=${2}
# Only for ACTION 'update':

View file

@ -5,8 +5,7 @@
# - DATABASE_DOVECOT_MASTERS
# Logic to perform for requested operations handled here:
function _manage_accounts
{
function _manage_accounts() {
local ACTION=${1}
local DATABASE=${2}
local MAIL_ACCOUNT=${3}
@ -60,8 +59,7 @@ function _manage_accounts_dovecotmaster_delete { _manage_accounts 'delete' "${DA
# - Calling external method '__usage' as part of error handling.
# Also used by setquota, delquota
function _arg_expect_mail_account
{
function _arg_expect_mail_account() {
[[ -z ${MAIL_ACCOUNT} ]] && { __usage ; _exit_with_error 'No account specified' ; }
# Dovecot Master accounts are validated (they are not email addresses):
@ -71,8 +69,7 @@ function _arg_expect_mail_account
[[ ${MAIL_ACCOUNT} =~ .*\@.* ]] || { __usage ; _exit_with_error "'${MAIL_ACCOUNT}' should include the domain (eg: user@example.com)" ; }
}
function _account_should_not_exist_yet
{
function _account_should_not_exist_yet() {
__account_already_exists && _exit_with_error "'${MAIL_ACCOUNT}' already exists"
if [[ -f ${DATABASE_VIRTUAL} ]] && grep -q "^${MAIL_ACCOUNT}" "${DATABASE_VIRTUAL}"; then
_exit_with_error "'${MAIL_ACCOUNT}' is already defined as an alias"
@ -80,20 +77,17 @@ function _account_should_not_exist_yet
}
# Also used by delmailuser, setquota, delquota
function _account_should_already_exist
{
function _account_should_already_exist() {
! __account_already_exists && _exit_with_error "'${MAIL_ACCOUNT}' does not exist"
}
function __account_already_exists
{
function __account_already_exists() {
local DATABASE=${DATABASE:-"${DATABASE_ACCOUNTS}"}
_db_has_entry_with_key "${MAIL_ACCOUNT}" "${DATABASE}"
}
# Also used by addsaslpassword
function _password_request_if_missing
{
function _password_request_if_missing() {
if [[ -z ${PASSWD} ]]; then
read -r -s -p 'Enter Password: ' PASSWD
echo

View file

@ -11,8 +11,7 @@
# mail to an alias address.
# Logic to perform for requested operations handled here:
function _manage_virtual_aliases
{
function _manage_virtual_aliases() {
local ACTION=${1}
local MAIL_ALIAS=${2}
local RECIPIENT=${3}

View file

@ -2,15 +2,13 @@
# Outputs the DNS label count (delimited by `.`) for the given input string.
# Useful for determining an FQDN like `mail.example.com` (3), vs `example.com` (2).
function _get_label_count
{
function _get_label_count() {
awk -F '.' '{ print NF }' <<< "${1}"
}
# Sets HOSTNAME and DOMAINNAME globals used throughout the scripts,
# and any subprocesses called that intereact with it.
function _obtain_hostname_and_domainname
{
function _obtain_hostname_and_domainname() {
# Normally this value would match the output of `hostname` which mirrors `/proc/sys/kernel/hostname`,
# However for legacy reasons, the system ENV `HOSTNAME` was replaced here with `hostname -f` instead.
#

View file

@ -1,7 +1,6 @@
#!/bin/bash
function _exit_with_error
{
function _exit_with_error() {
if [[ -n ${1+set} ]]; then
_log 'error' "${1}"
else
@ -19,8 +18,7 @@ function _exit_with_error
# PANIC_TYPE => (Internal value for matching). You should use the convenience methods below based on your panic type.
# PANIC_INFO => Provide your own message string to insert into the error message for that PANIC_TYPE.
# PANIC_SCOPE => Optionally provide a string for debugging to better identify/locate the source of the panic.
function dms_panic
{
function dms_panic() {
local PANIC_TYPE=${1:-}
local PANIC_INFO=${2:-}
local PANIC_SCOPE=${3:-}
@ -76,8 +74,7 @@ function _dms_panic__general { dms_panic 'general' "${1:-}" "${2:-}"
# `dms_panic` methods should be preferred if your failure type is supported.
trap "exit 1" SIGUSR1
SCRIPT_PID=${$}
function _shutdown
{
function _shutdown() {
_log 'error' "${1:-_shutdown called without message}"
_log 'error' 'Shutting down'
@ -91,13 +88,11 @@ function _shutdown
#
# This is mostly useful for debugging. It also helps when using something like `set -eE`,
# as it shows where the script aborts.
function _trap_err_signal
{
function _trap_err_signal() {
trap '__log_unexpected_error "${FUNCNAME[0]:-}" "${BASH_COMMAND:-}" "${LINENO:-}" "${?:-}"' ERR
# shellcheck disable=SC2317
function __log_unexpected_error
{
function __log_unexpected_error() {
local MESSAGE="Unexpected error occured :: script = ${SCRIPT:-${0}} "
MESSAGE+=" | function = ${1:-none (global)}"
MESSAGE+=" | command = ${2:-?}"

View file

@ -3,8 +3,7 @@
# shellcheck source-path=target/scripts/helpers
# This file serves as a single import for all helpers
function _import_scripts
{
function _import_scripts() {
local PATH_TO_SCRIPTS='/usr/local/bin/helpers'
source "${PATH_TO_SCRIPTS}/accounts.sh"

View file

@ -7,8 +7,7 @@ SCRIPT_NAME=$(basename "$0")
# prevent removal by other instances of docker-mailserver
LOCK_ID=$(uuid)
function _create_lock
{
function _create_lock() {
LOCK_FILE="/tmp/docker-mailserver/${SCRIPT_NAME}.lock"
while [[ -e "${LOCK_FILE}" ]]
do
@ -28,8 +27,7 @@ function _create_lock
echo "${LOCK_ID}" >"${LOCK_FILE}"
}
function _remove_lock
{
function _remove_lock() {
LOCK_FILE="${LOCK_FILE:-"/tmp/docker-mailserver/${SCRIPT_NAME}.lock"}"
[[ -z "${LOCK_ID}" ]] && _exit_with_error "Cannot remove '${LOCK_FILE}' as there is no LOCK_ID set"
if [[ -e "${LOCK_FILE}" ]] && grep -q "${LOCK_ID}" "${LOCK_FILE}"; then # Ensure we don't delete a lock that's not ours

View file

@ -42,8 +42,7 @@ RESET=$(echo -ne '\e[0m')
# If the first argument is not set or invalid, an error
# message is logged. Likewise when the second argument
# is missing. Both failures will return with exit code '1'.
function _log
{
function _log() {
if [[ -z ${1+set} ]]; then
_log 'error' "Call to '_log' is missing a valid log level"
return 1
@ -106,8 +105,7 @@ function _log
}
# Like `_log` but adds a timestamp in front of the message.
function _log_with_date
{
function _log_with_date() {
_log "${1}" "$(date '+%Y-%m-%d %H:%M:%S') ${2}"
}
@ -115,8 +113,7 @@ function _log_with_date
# it is set. Otherwise, try to query the common environment
# variables file. If this does not yield a value either,
# use the default log level.
function _get_log_level_or_default
{
function _get_log_level_or_default() {
if [[ -n ${LOG_LEVEL+set} ]]; then
echo "${LOG_LEVEL}"
elif [[ -e /etc/dms-settings ]] && grep -q -E "^LOG_LEVEL='[a-z]+'" /etc/dms-settings; then
@ -128,7 +125,6 @@ function _get_log_level_or_default
# This function checks whether the log level is the one
# provided as the first argument.
function _log_level_is
{
function _log_level_is() {
[[ $(_get_log_level_or_default) =~ ^${1}$ ]]
}

View file

@ -1,7 +1,6 @@
#!/bin/bash
function _mask_ip_digit
{
function _mask_ip_digit() {
if [[ ${1} -ge 8 ]]; then
MASK=255
elif [[ ${1} -le 0 ]]; then
@ -21,8 +20,7 @@ function _mask_ip_digit
# like 1.2.3.4/16 to subnet with cidr suffix
# like 1.2.0.0/16.
# Assumes correct IP and subnet are provided.
function _sanitize_ipv4_to_subnet_cidr
{
function _sanitize_ipv4_to_subnet_cidr() {
local DIGIT_PREFIX_LENGTH="${1#*/}"
declare -a MASKED_DIGITS DIGITS

View file

@ -17,8 +17,7 @@
# Should not be a concern for most types used by `docker-mailserver`: texthash, ldap, pcre, tcp, unionmap, unix.
# The only other type in use by `docker-mailserver` is the hash type for /etc/aliases, which `postalias` handles.
function _create_postfix_vhost
{
function _create_postfix_vhost() {
# `main.cf` configures `virtual_mailbox_domains = /etc/postfix/vhost`
# NOTE: Amavis also consumes this file.
local DATABASE_VHOST='/etc/postfix/vhost'
@ -29,8 +28,7 @@ function _create_postfix_vhost
}
# Filter unique values into a proper DATABASE_VHOST config:
function _create_vhost
{
function _create_vhost() {
: >"${DATABASE_VHOST}"
if [[ -f ${TMP_VHOST} ]]; then
@ -40,8 +38,7 @@ function _create_vhost
}
# Collects domains from configs (DATABASE_) into TMP_VHOST
function _vhost_collect_postfix_domains
{
function _vhost_collect_postfix_domains() {
local DATABASE_ACCOUNTS='/tmp/docker-mailserver/postfix-accounts.cf'
local DATABASE_VIRTUAL='/tmp/docker-mailserver/postfix-virtual.cf'
local DOMAIN UNAME
@ -75,8 +72,7 @@ function _vhost_collect_postfix_domains
# - `main.cf:mydestination` setting removes `$mydestination` as an LDAP bugfix.
# - `main.cf:virtual_mailbox_domains` uses `/etc/postfix/vhost`, but may
# conditionally include a 2nd table (ldap:/etc/postfix/ldap-domains.cf).
function _vhost_ldap_support
{
function _vhost_ldap_support() {
[[ ${ACCOUNT_PROVISIONER} == 'LDAP' ]] && echo "${DOMAINNAME}" >>"${TMP_VHOST}"
}

View file

@ -53,15 +53,13 @@
# That shouldn't be a breaking change, as long as the mapping is maintained correctly.
# TODO: RELAY_HOST should consider dropping `[]` and require the user to include that?
# Future refactor for _populate_relayhost_map may warrant dropping these two ENV in favor of DEFAULT_RELAY_HOST?
function _env_relay_host
{
function _env_relay_host() {
echo "[${RELAY_HOST}]:${RELAY_PORT:-25}"
}
# Responsible for `postfix-sasl-password.cf` support:
# `/etc/postfix/sasl_passwd` example at end of file.
function _relayhost_sasl
{
function _relayhost_sasl() {
if [[ ! -f /tmp/docker-mailserver/postfix-sasl-password.cf ]] \
&& [[ -z ${RELAY_USER} || -z ${RELAY_PASSWORD} ]]
then
@ -108,8 +106,7 @@ function _relayhost_sasl
# to a separate transport (which can drop the `relayhost` setting) would be more appropriate.
# TODO: With `sender_dependent_default_transport_maps`, we can extract out the excluded domains and route them through a separate transport.
# while deprecating that support in favor of a transport config, similar to what is offered currently via sasl_passwd and relayhost_map.
function _populate_relayhost_map
{
function _populate_relayhost_map() {
# Create the relayhost_map config file:
: >/etc/postfix/relayhost_map
chown root:root /etc/postfix/relayhost_map
@ -142,8 +139,7 @@ function _populate_relayhost_map
# map to a different relay-host, or use a separate transport (needs feature support added).
# Args: <PRINT_DOMAIN_PART_> <config filepath>
function _list_domain_parts
{
function _list_domain_parts() {
[[ -f $2 ]] && sed -n -r "/${MATCH_VALID}/ ${1}" "${2}"
}
# Matches and outputs (capture group via `/\1/p`) the domain part (value of address after `@`) in the config file.
@ -167,16 +163,14 @@ function _populate_relayhost_map
postconf 'sender_dependent_relayhost_maps = texthash:/etc/postfix/relayhost_map'
}
function _relayhost_configure_postfix
{
function _relayhost_configure_postfix() {
postconf \
'smtp_sasl_auth_enable = yes' \
'smtp_sasl_security_options = noanonymous' \
'smtp_tls_security_level = encrypt'
}
function _setup_relayhost
{
function _setup_relayhost() {
_log 'debug' 'Setting up Postfix Relay Hosts'
if [[ -n ${DEFAULT_RELAY_HOST} ]]; then
@ -194,8 +188,7 @@ function _setup_relayhost
fi
}
function _rebuild_relayhost
{
function _rebuild_relayhost() {
if [[ -n ${RELAY_HOST} ]]; then
_relayhost_sasl
_populate_relayhost_map

View file

@ -1,7 +1,6 @@
#!/bin/bash
function _setup_dhparam
{
function _setup_dhparam() {
local DH_SERVICE=$1
local DH_DEST=$2
local DH_CUSTOM='/tmp/docker-mailserver/dhparams.pem'
@ -18,8 +17,7 @@ function _setup_dhparam
fi
}
function _setup_ssl
{
function _setup_ssl() {
_log 'debug' 'Setting up SSL'
local POSTFIX_CONFIG_MAIN='/etc/postfix/main.cf'
@ -31,8 +29,7 @@ function _setup_ssl
mkdir -p "${DMS_TLS_PATH}"
# Primary certificate to serve for TLS
function _set_certificate
{
function _set_certificate() {
local POSTFIX_KEY_WITH_FULLCHAIN=${1}
local DOVECOT_KEY=${1}
local DOVECOT_CERT=${1}
@ -60,8 +57,7 @@ function _setup_ssl
}
# Enables supporting two certificate types such as ECDSA with an RSA fallback
function _set_alt_certificate
{
function _set_alt_certificate() {
local COPY_KEY_FROM_PATH=$1
local COPY_CERT_FROM_PATH=$2
local PRIVATE_KEY_ALT="${DMS_TLS_PATH}/fallback_key"
@ -88,8 +84,7 @@ function _setup_ssl
"${DOVECOT_CONFIG_SSL}"
}
function _apply_tls_level
{
function _apply_tls_level() {
local TLS_CIPHERS_ALLOW=$1
local TLS_PROTOCOL_IGNORE=$2
local TLS_PROTOCOL_MINIMUM=$3
@ -113,8 +108,7 @@ function _setup_ssl
# Extracts files `key.pem` and `fullchain.pem`.
# `_extract_certs_from_acme` is located in `helpers/ssl.sh`
# NOTE: See the `SSL_TYPE=letsencrypt` case below for more details.
function _traefik_support
{
function _traefik_support() {
if [[ -f /etc/letsencrypt/acme.json ]]; then
# Variable only intended for troubleshooting via debug output
local EXTRACTED_DOMAIN
@ -379,8 +373,7 @@ function _setup_ssl
# Identify a valid letsencrypt FQDN folder to use.
function _find_letsencrypt_domain
{
function _find_letsencrypt_domain() {
local LETSENCRYPT_DOMAIN
if [[ -n ${SSL_DOMAIN} ]] && [[ -e /etc/letsencrypt/live/$(_strip_wildcard_prefix "${SSL_DOMAIN}")/fullchain.pem ]]; then
@ -398,8 +391,7 @@ function _find_letsencrypt_domain
}
# Verify the FQDN folder also includes a valid private key (`privkey.pem` for Certbot, `key.pem` for extraction by Traefik)
function _find_letsencrypt_key
{
function _find_letsencrypt_key() {
local LETSENCRYPT_KEY
local LETSENCRYPT_DOMAIN=${1}
@ -419,8 +411,7 @@ function _find_letsencrypt_key
echo "${LETSENCRYPT_KEY}"
}
function _extract_certs_from_acme
{
function _extract_certs_from_acme() {
local CERT_DOMAIN=${1}
if [[ -z ${CERT_DOMAIN} ]]; then
_log 'warn' "_extract_certs_from_acme | CERT_DOMAIN is empty"

View file

@ -1,21 +1,18 @@
#!/bin/bash
function _escape
{
function _escape() {
echo "${1//./\\.}"
}
# Returns input after filtering out lines that are:
# empty, white-space, comments (`#` as the first non-whitespace character)
function _get_valid_lines_from_file
{
function _get_valid_lines_from_file() {
grep --extended-regexp --invert-match "^\s*$|^\s*#" "${1}" || true
}
# Provide the name of an environment variable to this function
# and it will return its value stored in /etc/dms-settings
function _get_dms_env_value
{
function _get_dms_env_value() {
if [[ -f /etc/dms-settings ]]; then
grep "^${1}=" /etc/dms-settings | cut -d "'" -f 2
else
@ -30,8 +27,7 @@ function _get_dms_env_value
#
# `helpers/accounts.sh:_create_accounts` (mkdir, cp) appears to be the only writer to
# /var/mail folders (used during startup and change detection handling).
function _chown_var_mail_if_necessary
{
function _chown_var_mail_if_necessary() {
# fix permissions, but skip this if 3 levels deep the user id is already set
if find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | read -r; then
_log 'trace' 'Fixing /var/mail permissions'
@ -39,8 +35,7 @@ function _chown_var_mail_if_necessary
fi
}
function _require_n_parameters_or_print_usage
{
function _require_n_parameters_or_print_usage() {
local COUNT
COUNT=${1}
shift
@ -55,15 +50,13 @@ function _require_n_parameters_or_print_usage
# After we modify the config explicitly, we can safely assume (reasonably)
# that the write stream has completed, and it is safe to read the config.
# https://github.com/docker-mailserver/docker-mailserver/issues/2985
function _adjust_mtime_for_postfix_maincf
{
function _adjust_mtime_for_postfix_maincf() {
if [[ $(( $(date '+%s') - $(stat -c '%Y' '/etc/postfix/main.cf') )) -lt 2 ]]; then
touch -d '2 seconds ago' /etc/postfix/main.cf
fi
}
function _reload_postfix
{
function _reload_postfix() {
_adjust_mtime_for_postfix_maincf
postfix reload
}
@ -92,8 +85,7 @@ 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
{
function _replace_by_env_in_file() {
if [[ -z ${1+set} ]]; then
_dms_panic__invalid_value 'first argument unset' 'utils.sh:_replace_by_env_in_file'
elif [[ -z ${2+set} ]]; then
@ -123,8 +115,7 @@ function _replace_by_env_in_file
# is not zero or one.
#
# @param ${1} = name of the ENV variable to check
function _env_var_expect_zero_or_one
{
function _env_var_expect_zero_or_one() {
local ENV_VAR_NAME=${1:?ENV var name must be provided to _env_var_expect_zero_or_one}
[[ ${!ENV_VAR_NAME} =~ ^(0|1)$ ]] && return 0
@ -138,8 +129,7 @@ function _env_var_expect_zero_or_one
# is not an integer.
#
# @param ${1} = name of the ENV variable to check
function _env_var_expect_integer
{
function _env_var_expect_integer() {
local ENV_VAR_NAME=${1:?ENV var name must be provided to _env_var_expect_integer}
[[ ${!ENV_VAR_NAME} =~ ^-?[0-9][0-9]*$ ]] && return 0