How to check if a variable is set in Bash
where ${var+x} is a parameter expansion which evaluates to nothing if var is unset, and substitutes the string x otherwise.
where ${var+x} is a parameter expansion which evaluates to nothing if var is unset, and substitutes the string x otherwise.