> Machine Type: i386-unknown-openbsd4.4 > > Bash Version: 4.0 > Patch Level: 0 > > Description: > playing with the associative arrays, bash ends up in what appears > to be a busy loop that I cannot interupt with C-c > > Repeat-By: > > > bash-4.0$ declare -A array > bash-4.0$ declare array["foo[bar"]=bleh > bash-4.0$ array["foo"]=bleh
You tricked the shell. Bash isn't smart enough to realize you're assigning to an associative array, and performs quote removal on the assignment before running `declare'. What ends up happening is that the shell tries to create a variable named 'array[foo[bar]=bleh', since the dequoted word is no longer a valid assignment statement. This leads to all sorts of weird behavior, since some of the code's assumptions are violated. The attached patch should catch the attempts to create invalid variables and flag them as errors. Chet
*** ../bash-4.0/builtins/declare.def 2009-01-04 14:32:22.000000000 -0500 --- builtins/declare.def 2009-02-25 09:41:35.000000000 -0500 *************** *** 288,291 **** --- 288,297 ---- } } + else if (legal_identifier (name) == 0) + { + sh_invalidid (name); + assign_error++; + NEXT_VARIABLE (); + } else value = "";
``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU c...@case.edu http://tiswww.tis.case.edu/~chet/