Created
May 8, 2020 20:22
-
-
Save RHDZMOTA/054c710cb2e803641374b0f8cbdf78a4 to your computer and use it in GitHub Desktop.
You can use the following function to check if an environment variable is set via parameter expansion. Early exit if it's not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function environ-check() { | |
local environ_tag="${1}" | |
local environ_val="${!1}" | |
if [[ -z "${environ_val}" ]] | |
then echo "Environ variable is not set ${environ_tag}"; exit 1 | |
fi | |
} | |
environ-check ENVIRON_VARIABLE_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment