> these two array subscripts, while > they appear identical, are not exactly the same: > > foo["a'b"]=two > unset foo["a'b"] > > The first does not undergo any word expansions before the array > assignment code runs, so that code performs the appropriate word > expansions (everything except word splitting and filename generation). > > The second undergoes the usual set of word expansions performed on all > command arguments, so the array code sees foo[a'b].
This implies to me that escaping the quotes in the unset line would cause the array code to see the same thing in both cases. That is, unset foo[\"a\'b\"] would mean that the pre-array code word expansions would result in foo["a'b"] being passed to the array code, the same as what that code sees in the assignment case. However, the net result of this modification is to change the script error message from "not a valid identifier" to "bad array subscript". > At some point, I may take a look at changing this, but it would not be > backwards compatible, and that is undesirable. It doesn't help you > now, either. Maintaining backwards compatibility while establishing consistent and logical behavior is definitely a balancing act! I have no opinion on this code change. The solution Greg provided solves my problem, and I'm happy with it. I do believe, however, that the existing documentation provides insufficient detail to work out Greg's solution.