someEmptyString=""
#a variable that was never set also reads as an empty string
unset anotherEmptyString
#-z is true for an empty string, -n for a non-empty one
if [[ -z "$someEmptyString" ]]; then
echo "someEmptyString is empty"
fi
length=${#someEmptyString}
#length is 0
#${var+set} gives "set" only for a variable that exists,
#so an unset variable can be told from an empty one
if [[ -z "${anotherEmptyString+set}" ]]; then
echo "anotherEmptyString is not set"
fi
echo "length is $length"