[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Awkward behavior of empty arrays
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] Awkward behavior of empty arrays |
Date: |
Thu, 7 Sep 2017 10:33:11 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 9/7/17 8:18 AM, Greg Wooledge wrote:
> On Thu, Sep 07, 2017 at 11:31:01AM +0200, Cristian Zoicas wrote:
>>> Hm, interesting. I think your whole message below can be rephrased as:
>>> empty arrays don't work with set -u. Is that right?
>>
>> right...
>
> You know, I'd been taking this assertion on faith, but after testing
> it, I just don't see any evidence that it's true.
It changed in bash-4.4:
3. New Features in Bash
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.
Originally, the nounset option worked on everything: variables, individual
positional parameters ($1), the set of positional parameters ($@), arrays,
special parameters that haven't gotten a value ($! when there haven't been
any asynchronous processes), etc. Posix decided on the special handling of
$@ in 2009, though treating $@ as a non-fatal error when there are no
positional parameters and nounset is enabled was not historical practice.
I changed the handling of address@hidden when A has no assigned elements to
match
that behavior.
--
``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/
- Re: [Help-bash] Awkward behavior of empty arrays, (continued)
- Re: [Help-bash] Awkward behavior of empty arrays, Cristian Zoicas, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Greg Wooledge, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Andy Chu, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Chris F.A. Johnson, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, DJ Mills, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Chet Ramey, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Andy Chu, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Chet Ramey, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Andy Chu, 2017/09/07
- Re: [Help-bash] Awkward behavior of empty arrays, Chet Ramey, 2017/09/09
- Re: [Help-bash] Awkward behavior of empty arrays,
Chet Ramey <=
Re: [Help-bash] Awkward behavior of empty arrays, Andy Chu, 2017/09/06