5

How to test if a variable is defined at all in Bash prior to version 4.2 with the nounset shell option?

view full story
linux-howto

http://unix.stackexchange.com – For Bash versions prior to "GNU bash, Version 4.2" are there any equivalent alternatives for the -v option of the test command? For example: shopt -os nounset test -v foobar && echo foo || echo bar # Output: bar foobar= test -v foobar && echo foo || echo bar # Output: foo (HowTos)