From ae3feebd80195bd467262208f2cdada1b3fc458b Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Mon, 3 May 2021 19:04:59 -0400 Subject: [PATCH] Fix warnings reported by shellcheck * SC2068: Double quote array expansions to avoid re-splitting elements. * SC2186: tempfile is deprecated. Use mktemp instead. * SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. * SC2102: Ranges can only match single chars (mentioned due to duplicates). * SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. --- setup/functions.sh | 9 ++++----- setup/mail-postfix.sh | 2 +- setup/start.sh | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/setup/functions.sh b/setup/functions.sh index 90c4c55d..718a2283 100644 --- a/setup/functions.sh +++ b/setup/functions.sh @@ -9,12 +9,12 @@ function hide_output { # and returns a non-zero exit code. # Get a temporary file. - OUTPUT=$(tempfile) + OUTPUT=$(mktemp) # Execute command, redirecting stderr/stdout to the temporary file. Since we # check the return code ourselves, disable 'set -e' temporarily. set +e - $@ &> $OUTPUT + "$@" &> $OUTPUT E=$? set -e @@ -22,7 +22,7 @@ function hide_output { if [ $E != 0 ]; then # Something failed. echo - echo FAILED: $@ + echo FAILED: "$@" echo ----------------------------------------- cat $OUTPUT echo ----------------------------------------- @@ -53,8 +53,7 @@ function apt_install { # install' for all of the packages. Calling `dpkg` on each package is slow, # and doesn't affect what we actually do, except in the messages, so let's # not do that anymore. - PACKAGES=$@ - apt_get_quiet install $PACKAGES + apt_get_quiet install "$@" } function get_default_hostname { diff --git a/setup/mail-postfix.sh b/setup/mail-postfix.sh index 0a66cb0f..b16fd94a 100755 --- a/setup/mail-postfix.sh +++ b/setup/mail-postfix.sh @@ -191,7 +191,7 @@ tools/editconf.py /etc/postfix/main.cf \ # # In a basic setup we would pass mail directly to Dovecot by setting # virtual_transport to `lmtp:unix:private/dovecot-lmtp`. -tools/editconf.py /etc/postfix/main.cf virtual_transport=lmtp:[127.0.0.1]:10025 +tools/editconf.py /etc/postfix/main.cf "virtual_transport=lmtp:[127.0.0.1]:10025" # Because of a spampd bug, limit the number of recipients in each connection. # See https://github.com/mail-in-a-box/mailinabox/issues/1523. tools/editconf.py /etc/postfix/main.cf lmtp_destination_recipient_limit=1 diff --git a/setup/start.sh b/setup/start.sh index cedc426d..b4e38e65 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -78,7 +78,7 @@ if [ ! -d $STORAGE_ROOT ]; then mkdir -p $STORAGE_ROOT fi if [ ! -f $STORAGE_ROOT/mailinabox.version ]; then - echo $(setup/migrate.py --current) > $STORAGE_ROOT/mailinabox.version + setup/migrate.py --current > $STORAGE_ROOT/mailinabox.version chown $STORAGE_USER.$STORAGE_USER $STORAGE_ROOT/mailinabox.version fi