Re: Question about associative array runtime assignment vs literal initialization

Koichi Murase <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <CAFLRLk_D1AoTvG8sqo4PHRvfyj=SDwmTtPbLDaVt_dDf6AemeA@mail.gmail.com>
2026年1月6日(火) 0:19 Chet Ramey <[email protected]>:
> [...]
>
> You might want to read Koichi's proposal.
>
> https://lists.gnu.org/archive/html/bug-bash/2025-12/msg00125.html

@Greg In particular, it is clear to read the pseudocode at the end of
the above link.

> It goes further than I'd like, in that his proposal supports subscripted
> array element assignment mixed with kvpair assignment. It doesn't propose
> to change how subcripted assignments work, or how to determine whether or
> not the compound assignment is subscripted or k-v pairwise assignment.

I think this is the only way that is consistent with the traditional
behavior of the compound list for the indexed arrays.

> > Maybe a new command like this would be the cleanest way forward.  A
> > bash equivalent might look something like:
> >
> >      loadarray assoc "${kv[@]}"
> >
> > Maybe add an option that'll clear any existing elements.
>
> This sounds like a loadable builtin, if someone wants to take a run at it.

Actually, users can implement these [1] as shell functions.

[1] Greg's `array' and `loadarray' suggested in
https://lists.gnu.org/archive/html/bug-bash/2026-01/msg00008.html

--
Koichi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.