I have a bash script that runs a check to determine if the requisite environment variables are set before executing its logic.
At the moment I'm repeating the following code block for every environment variable:
if [[ -z "$SOME_ENV_VAR" ]]; then
echo "Warning - the SOME_ENV_VAR environment variable isn't set"
exit 1
fi
Is there a way to declare an array and iterate over the array and check if the environment variable is set?
I know how to iterate over arrays in bash, but I'm not sure how to use each iteration variable to check if a similarly named environment variable is present.