A simple Bash variable test goes:
${varName:? \"${varName} is not defined\"}
I\'d like to re-use this, by putting it in a function. How
Unsure if this is exactly what you want but a handy trick I use when writing a new+complex script is to use "set -o"
set -o #will make the script bomb out when it finds an unset variable
EG:
$ grep '$1' chex.sh
case "$1" in
$ ./chex.sh
./chex.sh: line 111: $1: unbound variable
$ ./chex.sh foo
incorrect/no options passed.. exiting