Re: bug: readonly array that is empty causes error (whereas not empty do
From:
Chet Ramey
Subject:
Re: bug: readonly array that is empty causes error (whereas not empty does not)
Date:
Wed, 23 Dec 2015 08:40:47 -0500
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
On 12/23/15 1:49 AM, James Thomas Moon wrote:
> The following script is okay
>
> set -ue
> readonly -a a=('')
>
> Yet, the following script fails with exit code 1
>
> set -ue
> readonly -a a=()
>
> In my case, I would like to preserve a copy of all passed arguments:
>
> set -ue
> readonly -a ARGS=("${@}")
>
> If no arguments are passed then the script fails. It's surprising the
> error behavior diverges depending upon setting an empty array or non-empty
> array.
I can't reproduce this in any bash version going back to bash-2.05b.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/