2025年12月23日(火) 0:21 Greg Wooledge <[email protected]>:
> hobbit:~$ declare -A aa=("${kv[@]}"); declare -p aa
> declare -A aa=(["one 1 two 2 two and a half 2.5 three 3"]="" )

I agree that the above behavior is wrong.

> hobbit:~$ declare -A aa="("${kv[@]}")"; declare -p aa
> declare -A aa=([3]="" [a]="half" [two]="and" [2.5]="three" [one]="1" )

However, I agree with Chet that the above is the correct behavior. In
this example, ${kv[@]} is outside the double quoting (because the
first double quotation is « "(" » and the second double quotation is «
")" »), and then the bare ${kv[@]} is subject to word splitting so
that "two and a half" are split into four words "two", "and", "a", and
"half". Could you describe the reason that you think this is wrong?

> Both of these are "wrong" from the point of view of everybody but Chet.

No, at least, the latter is correct from my perspective. And, in
my perspective, the two cases are actually completely different.

--
Koichi

  • Question about... 王伟
    • Re: Quest... Greg Wooledge
      • Re: Q... Koichi Murase
        • R... Greg Wooledge
          • ... Zachary Santer
            • ... Greg Wooledge
          • ... Koichi Murase
            • ... Koichi Murase
          • ... Félix Hauri via Bug reports for the GNU Bourne Again SHell
            • ... Greg Wooledge
              • ... Félix Hauri via Bug reports for the GNU Bourne Again SHell
                • ... Félix Hauri via Bug reports for the GNU Bourne Again SHell
                • ... Greg Wooledge

Reply via email to