Use more portable method to test if variable is set

Older versions of bash don't support [[ -v var ]].