help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing the way bash expands associative array subscripts


From: konsolebox
Subject: Re: Changing the way bash expands associative array subscripts
Date: Fri, 16 Apr 2021 05:58:32 +0800

On Fri, Apr 16, 2021 at 12:10 AM Chet Ramey <chet.ramey@case.edu> wrote:
> > I actually agree with konsolebox that assoc_expand_once for unset
> > shouldn't be defaulted.  The option `assoc_expand_once' is incomplete
> > in the sense that the behavior of `a[@]' and `a[*]' are subtle.  I see
> > the current default behavior (with `assoc_expand_once' turned off)
> > more consistent and clean.
>
> Yeah, maybe. But explaining the requirements for quoting things in multiple
> ways is confusing, even to experienced users, and leads to knee-jerk
> overreactions like "don't use associative arrays ever" that don't help
> anyone. That's one of the motivations for this entire discussion.

I think the best compromise here is to have unset converted to a
special builtin like local so tokens like `a[$key]`, `a["$key"]`, and
`a[@]` are directly parsed but keep the old re-evaluating behavior on
string arguments like `'a[$key]'`.  This will make everyone happy and
avoid scripts from breaking.

This behavior would entirely be independent from assoc_expand_once and
would simply be a subject for compat.  I don't see compat-ing it
necessary though.

-- 
konsolebox



reply via email to

[Prev in Thread] Current Thread [Next in Thread]