Created
November 13, 2015 15:11
-
-
Save andresrc/e912de12ac22bada2e93 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# Preamble | |
PROGNAME=$(basename $0) | |
function error_exit | |
{ | |
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 | |
exit ${2:-1} | |
} | |
# Argument validation | |
[[ -z "$1" ]] && error_exit "Variable Name to check must be provided" 1 | |
[[ -z "$2" ]] && error_exit "Expected variable value must be provided" 2 | |
NAME=$1 | |
EVALUE=$2 | |
# Get real value | |
RVALUE="${!NAME}" | |
# Compare | |
[[ "$RVALUE" = "$EVALUE" ]] || error_exit "Real Value [$RVALUE] different from expected value [$EVALUE]" 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment