[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: An array variable created by export/readonly builtins inside a funct
From: |
Chet Ramey |
Subject: |
Re: An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly |
Date: |
Sat, 5 Dec 2015 15:18:09 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
On 11/27/15 10:18 PM, ziyunfei wrote:
> $ ksh -c 'foo() { readonly a=(1);echo a=$a; }; foo; echo a=$a'
> a=1
> a=1
> $ bash -c 'foo() { readonly a=(1);echo a=$a; }; foo; echo a=$a' # a becomes a
> local variable
> a=1
> a=
Thanks for the report. I agree that this is a bug. `readonly' and
`export' should not create local variables when invoked within a function;
only declare/local/typeset should create local variables.
This will be fixed in the next release of bash.
Chet
--
``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/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly,
Chet Ramey <=