On 11/26/12 4:45 PM, Tim Friske wrote: > Hi folks, > > I execute the following code in Bash version "GNU bash, Version > 4.2.39(1)-release (x86_64-redhat-linux-gnu)": > > function foobar { > declare -rgA FOOBAR=([foo]=bar) > } > foobar > declare -p FOOBAR > # Output: declare -Ar FOOBAR='()' > > Why doesn't Bash initialize FOOBAR with ([foo]=bar) according to > declare -p?
Thanks for the report. Bash does things internally so that the above statement is executed as if it were declare -Ag FOOBAR FOOBAR=([foo]=bar) declare -r FOOBAR The problem was with the code that simulated the first statement, which did not correctly handle the `-g' option. There are actually two variables created: one function-local with the correct value (but not all the right attributes), and one global with no value, but with the correct attributes. This will be fixed in the next version. 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/