Sometimes you might want to exit a command if a variable is not set in Bash.

You can do this as follows:

1
if [ -z "$VARIABLE_NAME" ]; then echo "VARIABLE_NAME is not set"; exit 1; fi