On Mon, 22 May 2023, 12:59 Emanuele Torre, <torreemanue...@gmail.com> wrote:
> I am not really proposing a major change to the behaviour of nounset, I > am only pointing out the incorrect bash behaviour for that case. I disagree: this would constitute a major change, breaking behaviour that is (for good reasons) depended on. It's my opinion that the current behaviour is "working as intended" and doesn't need fixing. It's not perfect but it's better than the alternatives. There's no parallel with "misspelt variable name", since it's unlikely that referencing an unset array slot constitutes a programmer typo. Rather it's more in the nature of a potential logic error; or may in fact be working exactly as intended. It may be tempting to suggest that we could "be explicit" and change "a[x]" to "${a[x]-0}" in numeric context. I think that cure would be worse than the disease, because it has undesirable hidden effects on operator precedence and order of evaluation. -Martin