Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11948
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly |
| Date | 2015-12-05 15:18 -0500 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.1467.1449346701.31583.bug-bash@gnu.org> (permalink) |
| References | <70266BC6-C65A-4D95-B7C1-2F63F3C45DEF@qq.com> |
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/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly Chet Ramey <chet.ramey@case.edu> - 2015-12-05 15:18 -0500
csiph-web