Skip to content

Instantly share code, notes, and snippets.

@tonicebrian
Created September 17, 2019 07:30
Show Gist options
  • Save tonicebrian/fcdf1228e31735c12c6ffc9c978a522f to your computer and use it in GitHub Desktop.
Save tonicebrian/fcdf1228e31735c12c6ffc9c978a522f to your computer and use it in GitHub Desktop.
Check for variables defined in bash script
for var in MY_ENV_VAR_1 MY_ENV_VAR_2; do
if [[ -z "${!var:-}" ]];
then
echo "You need to provide a value for env variable $var"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment