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    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to