From 2977cb6962ee6451ab6466034ad47858a9d40875 Mon Sep 17 00:00:00 2001 From: Casper Date: Thu, 5 May 2022 17:48:21 +0200 Subject: [PATCH] Streamline 'printf' usage and consequently use a format string (#2564) --- setup.sh | 16 ++++++++-------- target/scripts/startup/setup-stack.sh | 2 +- test/mail_ssl_manual.bats | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/setup.sh b/setup.sh index e0dd8aef..a82b256e 100755 --- a/setup.sh +++ b/setup.sh @@ -19,11 +19,11 @@ USE_SELINUX= USE_TTY= VOLUME= -RED="\e[31m\e[1m" -WHITE="\e[37m" -ORANGE="\e[38;5;214m" -LBLUE="\e[94m" -RESET="\e[0m" +RED=$(echo -ne '\e[31m\e[1m') +WHITE=$(echo -ne '\e[37m') +ORANGE=$(echo -ne '\e[38;5;214m') +LBLUE=$(echo -ne '\e[94m') +RESET=$(echo -ne '\e[0m') set -euEo pipefail shopt -s inherit_errexit 2>/dev/null || true @@ -47,7 +47,7 @@ function __err function _show_local_usage { # shellcheck disable=SC2059 - printf "${ORANGE}OPTIONS${RESET} + printf '%s' "${ORANGE}OPTIONS${RESET} ${LBLUE}Config path, container or image adjustments${RESET} -i IMAGE_NAME Provides the name of the 'docker-mailserver' image. The default value is @@ -78,7 +78,7 @@ function _show_local_usage [[ ${1:-} == 'no-exit' ]] && return 0 # shellcheck disable=SC2059 - printf "${ORANGE}EXIT STATUS${RESET} + printf '%s' "${ORANGE}EXIT STATUS${RESET} Exit status is 0 if the command was successful. If there was an unexpected error, an error message is shown describing the error. In case of an error, the script will exit with exit status 1. @@ -231,7 +231,7 @@ function _main _run_in_new_container setup "${@}" fi - [[ ${1} == 'help' ]] && _show_local_usage + [[ ${1:-} == 'help' ]] && _show_local_usage return 0 } diff --git a/target/scripts/startup/setup-stack.sh b/target/scripts/startup/setup-stack.sh index d6e7159d..56979936 100644 --- a/target/scripts/startup/setup-stack.sh +++ b/target/scripts/startup/setup-stack.sh @@ -155,7 +155,7 @@ function _setup_dovecot if ! grep -q -E '^stats_writer_socket_path=' /etc/dovecot/dovecot.conf then - printf '\nstats_writer_socket_path=\n' >>/etc/dovecot/dovecot.conf + printf '\n%s\n' 'stats_writer_socket_path=' >>/etc/dovecot/dovecot.conf fi # set mail_location according to mailbox format diff --git a/test/mail_ssl_manual.bats b/test/mail_ssl_manual.bats index 81e326a0..287734cf 100644 --- a/test/mail_ssl_manual.bats +++ b/test/mail_ssl_manual.bats @@ -99,7 +99,7 @@ function teardown_file() { } @test "checking ssl: manual cert changes are picked up by check-for-changes" { - printf 'someThingsChangedHere' \ + printf '%s' 'someThingsChangedHere' \ >>"$(pwd)/test/test-files/ssl/${DOMAIN_SSL_MANUAL}/with_ca/ecdsa/key.ecdsa.pem" run timeout 15 docker exec mail_manual_ssl bash -c "tail -F /var/log/supervisor/changedetector.log | sed '/Manual certificates have changed/ q'"