On Sat, Nov 28, 2015 at 11:18:24AM +0800, ziyunfei wrote:
> $ bash -c 'foo() { readonly a=(1);echo a=$a; }; foo; echo a=$a' # a becomes a
> local variable
> a=1
> a="readonly" is a synonym for "declare -r", and declare (without the -g option) always marks variables as local when used in a function. If you want variables created in a function NOT to be local to that function, you must skip all declarations entirely. Just create the variable by assigning to it.
