From da43a5abbf0300076ad18719f005b58aa953c11f Mon Sep 17 00:00:00 2001 From: Felix Bartels <1257835+fbartels@users.noreply.github.com> Date: Fri, 6 Sep 2019 13:10:03 +0200 Subject: [PATCH] define exit trap after checking for reg (#235) otherwise script would print an undefined variable for tmpfile Signed-off-by: Felix Bartels --- setup-update-tag.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup-update-tag.sh b/setup-update-tag.sh index fbb06e3..8571e3d 100755 --- a/setup-update-tag.sh +++ b/setup-update-tag.sh @@ -3,13 +3,6 @@ set -euo pipefail IFS=$'\n\t' -function finish { - if [ -e "$tmpfile" ]; then - rm "$tmpfile" - fi -} -trap finish EXIT - if ! command -v reg > /dev/null; then echo "Please install reg in order to run this script." exit 1 @@ -20,6 +13,13 @@ if [ ! -e ./.env ]; then exit 1 fi +function finish { + if [ -e "$tmpfile" ]; then + rm "$tmpfile" + fi +} +trap finish EXIT + # this is a kind of ugly hack to be able to source the env file # this is sadly needed since postfix in https://github.com/tomav/docker-mailserver/ cannot deal with quoted values tmpfile=$(mktemp /tmp/kopano-docker-env.XXXXXX)