Re: Question about associative array runtime assignment vs literal initialization

Greg Wooledge <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <[email protected]>
On Mon, Dec 22, 2025 at 10:46:12 +0800, 王伟 wrote:
> But when using runtime assignment:
> 
> local -A params=("$@")
> 
> or:
> 
> declare -A params=("${array[@]}")
> 
> Bash does not interpret the arguments as key/value pairs, and instead
> produces something like:
> 
> declare -p params
> declare -A params=(["a 1 b 2"]="")
> 
> My question is:
> 
> Is this behavior intentional design, or is it considered a bug / limitation
> of associative array assignment?
> 
> If this is intentional, could you clarify why runtime assignment does not
> follow the same key/value parsing rules as literal initialization?

This came up just two weeks ago, in the thread starting at
<https://lists.gnu.org/archive/html/bug-bash/2025-12/msg00026.html>.

I constructed an example very similar to yours, and Chet's response
is here: <https://lists.gnu.org/archive/html/bug-bash/2025-12/msg00032.html>
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.