On Tue, Dec 21, 2021, at 10:48 PM, Dale R. Worley wrote:
> Lawrence Velázquez <v...@larryv.me> writes:
>> Did you mean to say that ${#FOO[*]} causes an error?  Because
>> ${FOO[*]} does not, a la $*:
>
> The case that matters for me is the Bash that ships with "Oracle Linux".
> Which turns out to be version 4.2.46(2) from 2011, which is a lot older
> than I would expect.  But it *does* cause an error in that verison:
>
>     $ ( set -u ; FOO=() ; echo "${FOO[@]}" )
>     bash: FOO[@]: unbound variable
>     $ bash -uc ': "${FOO[*]}"'
>     bash: FOO[*]: unbound variable
>     $ 
>
>> Like ${FOO[*]}, ${FOO[@]} and $@ are exempt from ''set -u''.
>
> It looks like that's a change since 4.2.46.

Yes, it appears to be from 4.4.

https://git.savannah.gnu.org/cgit/bash.git/tree/CHANGES?id=15409324f1974d41c183904ad575da7188058c1c#n1512

    This document details the changes between this version,
    bash-4.4-rc2, and the previous version, bash-4.4-beta2.

    [...]

    3.  New Features in Bash

    a.  Using ${a[@]} or ${a[*]} with an array without any assigned
        elements when the nounset option is enabled no longer throws
        an unbound variable error.


> Is there text in the manual page about that?

I don't know.

-- 
vq

Reply via email to