Skip to content

Instantly share code, notes, and snippets.

@rankun203
Created January 18, 2018 02:04
Show Gist options
  • Save rankun203/9bc36db2fd90240055727b61e0be7360 to your computer and use it in GitHub Desktop.
Save rankun203/9bc36db2fd90240055727b61e0be7360 to your computer and use it in GitHub Desktop.
Ensure environment is exist and empty
#!/usr/bin/env bash
# Functions --------
ensure_env () {
ENV_NAME="$1"
ENV_VAL=${!ENV_NAME}
if [[ -z "${ENV_VAL}" ]]; then
echo "${ENV_NAME} does not exists, exiting."
exit
else
echo "$ENV_NAME = ${ENV_VAL}"
fi
}
# END Functions ----
# Init -------------
ensure_env GIT_BRANCH
ensure_env GIT_REPO_DIR
ensure_env GIT_REPO
ensure_env GIT_NAME
ensure_env GIT_EMAIL
# END Init ---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment