Skip to main content
2 of 3
Added code formatting
Thor
  • 17.5k
  • 3
  • 55
  • 71

I use the same technique for all variables in bash, and it works, e.g.:

[ ${foobar[@]} ] && echo "foobar is set" || echo "foobar is unset"

outputs:

foobar is unset

whilst

foobar=( "val" )
[ ${foobar[@]} ] && echo "foobar is set" || echo "foobar is unset"

outputs:

foobar is set