bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zero-length indexed arrays


From: Lawrence Velázquez
Subject: Re: Zero-length indexed arrays
Date: Thu, 16 Dec 2021 23:56:08 -0500
User-agent: Cyrus-JMAP/3.5.0-alpha0-4524-g5e5d2efdba-fm-20211214.001-g5e5d2efd

On Thu, Dec 16, 2021, at 11:45 PM, Lawrence Velázquez wrote:
> Did you mean to say that ${#FOO[*]} causes an error?  Because
> ${FOO[*]} does not, à la $*:
>
> [...]
>
> Like ${FOO[*]}, ${FOO[@]} and $@ are exempt from ''set -u''.

Perhaps you're using an old bash, like the one shipped with macOS?

    % /bin/bash --version | head -n 1
    GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
    % /bin/bash -uc ': "${FOO[*]}"'
    /bin/bash: FOO[*]: unbound variable
    % /bin/bash -uc ': "${FOO[@]}"'
    /bin/bash: FOO[@]: unbound variable

If so, there's not much anyone here can do about it.

-- 
vq



reply via email to

[Prev in Thread] Current Thread [Next in Thread]