Skip to content

Instantly share code, notes, and snippets.

@andresrc
Created November 13, 2015 15:11
Show Gist options
  • Save andresrc/e912de12ac22bada2e93 to your computer and use it in GitHub Desktop.
Save andresrc/e912de12ac22bada2e93 to your computer and use it in GitHub Desktop.
#!/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