A bit ago I was debugging a failing script at work.  It turns out that
when you say
    FOO=(x y z)
then the variable FOO is an array and is defined.  But when you say
    FOO=()
then the variable FOO is an array (because ${#FOO[*]} substitutes an
integer viz. 0) but it is *not* defined (because ${FOO[*]} generates an
error when "set -u" is in effect).

I really don't like this.  But it is according to the manual (because
FOO has no index that has a value), and no doubt there are scripts out
there that depend subtly on this case.

It turns out that this can matter, if you do something like this:

    set -u    # for safety
    ...
    if ...
    then
        FOO=(...)
    else
        FOO=()
    fi
    ...
    FOO_PLUS=("${FOO[@]}" x y z w)

Dale

Reply via email to