From 9729e7657fc4ca76d3e71be74d3df2994e81dcbd Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Fri, 23 Sep 2016 09:41:08 +0200 Subject: [PATCH] Improve checking functions --- gitlab/functions.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gitlab/functions.sh b/gitlab/functions.sh index b20e115..df3037c 100644 --- a/gitlab/functions.sh +++ b/gitlab/functions.sh @@ -31,7 +31,18 @@ check_env() { log_error "Variable ${1} is undefined - aborting..."; exit 1 else - log_info "Variable ${1}: OK"; + log_info "\$${1}= ${!1}"; + fi +} + + +# Checks a given environment variable is set (non-zero size) +check_pass() { + if [ -z "${!1}" ]; then + log_error "Variable ${1} is undefined - aborting..."; + exit 1 + else + log_info "\$${1}= ********"; fi } @@ -61,7 +72,7 @@ setup() { dot_pypirc() { check_env PYPISERVER check_env PYPIUSER - check_env PYPIPASS + check_pass PYPIPASS log_info "Creating ~/.pypirc..." cat <<EOT >> ~/.pypirc [distutils] @@ -87,7 +98,7 @@ EOT doc_upload() { check_env DOCSERVER check_env DOCUSER - check_env DOCPASS + check_pass DOCPASS log_info "${1} -> ${DOCSERVER}/${2}, via curl..." curl --silent --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2} local status=$? -- GitLab