On Thu, Oct 13, 2022 at 02:35:55PM -0400, Chet Ramey wrote: > On 10/13/22 12:47 PM, Bryan Roessler wrote: > > For indexed arrays, yes. I hadn't made the connection with associative > > arrays since I don't typically index them with numbers, thanks. > > There has to be some default, and "0" is at least consistent with indexed > arrays.
I actually would have preferred an error message. Something like "bash: test: missing array index" would have been clear enough for me. The current behavior is absolutely mystifying for most people. I'm not actually requesting a change. I recognize that it's far too late for that. Hmm... If at some point you choose to add a shopt that turns on extra warnings, I'd love it if *this* could be included in said warnings. The use of an array variable with no index, having index "0" be chosen for you, is worthy of a warning, in such a hypothetical mode.