From 0cf94807b9f603f37b43c30102c01fcd3bfe6684 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Thu, 22 Dec 2016 22:44:45 +0100 Subject: [PATCH] Better test for variable undefined --- gitlab/functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab/functions.sh b/gitlab/functions.sh index b6fe2ec..bf52fd7 100644 --- a/gitlab/functions.sh +++ b/gitlab/functions.sh @@ -27,7 +27,7 @@ log_error() { # Checks a given environment variable is set (non-zero size) check_env() { - if [ -z "${!1}" ]; then + if [ -z "${1+abc}" ]; then log_error "Variable ${1} is undefined - aborting..."; exit 1 else @@ -38,7 +38,7 @@ check_env() { # Exports a given environment variable, verbosely export_env() { - if [ -z "${!1}" ]; then + if [ -z "${1+abc}" ]; then log_error "Variable ${1} is undefined - aborting..."; exit 1 else @@ -50,7 +50,7 @@ export_env() { # Checks a given environment variable is set (non-zero size) check_pass() { - if [ -z "${!1}" ]; then + if [ -z "${1+abc}" ]; then log_error "Variable ${1} is undefined - aborting..."; exit 1 else -- GitLab