bug-bash
[Top][All Lists]
Advanced

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

Re: "set -u" and empty arrays


From: Chet Ramey
Subject: Re: "set -u" and empty arrays
Date: Mon, 13 May 2019 15:44:11 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

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.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

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