bug-bash
[Top][All Lists]
Advanced

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

Re: [4.4.5] trouble declaring readonly array variables


From: Chet Ramey
Subject: Re: [4.4.5] trouble declaring readonly array variables
Date: Sun, 4 Dec 2016 21:02:23 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0

On 12/3/16 10:26 PM, Laur Aliste wrote:
> Hi,
> upgraded bash from
> GNU bash, version *4.3.30(1)-release* (x86_64-pc-linux-gnu)
> to *4.4.5(1)-release* and noticed the *readonly* array variables fail to be
> defined with init values.

This was changed as the result of a bug report from December, 2015:

http://lists.gnu.org/archive/html/bug-bash/2015-11/msg00140.html

`readonly' and `export' create global variables by default.  They're
Posix builtins, and that's how Posix works (and other shells, like
ksh93).  There was an inconsistency in how they treated array declarations,
and that's what the change addressed.

If you want i and j to be treated as array variables, declare them as array
variables.  Something like

o()
{
        declare -ar i=($1)
        declare -ar j=(1 2 3)

        [and so on...]
}

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



reply via email to

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