On Tue, Dec 23, 2025 at 9:47 AM Chet Ramey <[email protected]> wrote:
>
> On 12/22/25 10:01 AM, Koichi Murase wrote:
> > 2025年12月22日(月) 22:40 Greg Wooledge <[email protected]>:
> >> On Mon, Dec 22, 2025 at 10:46:12 +0800, 王伟 wrote:
> >>> Is this behavior intentional design, or is it considered a bug / 
> >>> limitation
> >>> of associative array assignment?
> >
> > I believe « declare -A assoc=("${kv[@]}") » should be supported [where
> > kv is an indexed array in the form kv=(key1 value1 key2 value2 ...)].
>
> https://lists.gnu.org/archive/html/bug-bash/2025-12/msg00030.html
>
> explains why this doesn't happen. It seems like you want a different
> order of operations.

On Tue, Dec 23, 2025 at 10:03 AM Chet Ramey <[email protected]> wrote:
>
> On 12/22/25 11:05 AM, Koichi Murase wrote:
> > 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.
>
> You would like word splitting in this one specific case? Treating `declare'
> as a declaration utility in all cases except this one?

$ declare -a array1=( zero one two three four five )
$ declare -a array2=( "${array1[@]:0:3}" )
$ declare -p array1 array2
declare -a array1=([0]="zero" [1]="one" [2]="two" [3]="three"
[4]="four" [5]="five")
declare -a array2=([0]="zero" [1]="one" [2]="two")

Is 'declare' not being treated as a declaration utility here? We're
asking for *the same* behavior in the case of an associative array,
the only difference being that the expanded words are "interpreted as
a sequence of alternating keys and values."

  • Re: Question a... Greg Wooledge
    • Re: Quest... Koichi Murase
      • Re: Q... Greg Wooledge
        • R... Zachary Santer
          • ... Greg Wooledge
        • R... Koichi Murase
          • ... Koichi Murase
            • ... Chet Ramey
              • ... Koichi Murase
          • ... Chet Ramey
            • ... Zachary Santer
            • ... Koichi Murase
        • R... 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
      • Re: Q... Chet Ramey
        • R... Koichi Murase

Reply via email to