bug-bash
[Top][All Lists]
Advanced

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

Antw: Re: "set -u" and empty arrays


From: Ulrich Windl
Subject: Antw: Re: "set -u" and empty arrays
Date: Tue, 14 May 2019 08:53:53 +0200

>>> Chet Ramey <address@hidden> schrieb am 13.05.2019 um 21:44 in Nachricht
<address@hidden>:
> On 5/9/19 7:07 AM, Ulrich Windl wrote:
>> Bash Version: 4.3
>> Patch Level: 48
>> Release Status: release
>> 
>> Hi!
>> 
>> Is this intended with "set -u":
>> # set -u
>> # declare -a INSTANCES
>> # echo ${INSTANCES[*]}
>> bash: INSTANCES[*]: unbound variable
>> # INSTANCES=()
>> # echo ${INSTANCES[*]}
>> bash: INSTANCES[*]: unbound variable
>> # echo address@hidden
>> bash: address@hidden: unbound variable
> 
> This was changed late in the bash-4.4 development cycle (July, 2016). From
> bash-4.4/CHANGES:
> 
> a.  Using address@hidden or ${a[*]} with an array without any assigned 
> elements 
> when
>     the nounset option is enabled no longer throws an unbound variable 
> error.

Thanks for the info! Actually it seems "${#a[*]}" is also affected:
v04:~> declare -a a
v04:~> echo address@hidden
0
v04:~> set -u
v04:~> echo address@hidden
bash: a: unbound variable
v04:~> a=()
v04:~> echo address@hidden
0
v04:~> echo $BASH_VERSION
4.3.48(1)-release

Regards,
Ulrich







reply via email to

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