[Top][All Lists]

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

Re: No word splitting for assignment-like expressions in compound assign

From: Chet Ramey
Subject: Re: No word splitting for assignment-like expressions in compound assignment
Date: Tue, 28 Jul 2020 10:22:35 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 7/23/20 8:11 PM, Alexey Izbyshev wrote:
> Hello!
> I have a question about the following behavior:
> $ Z='a b'
> $ A=(X=$Z)
> $ declare -p A
> declare -a A=([0]="X=a b")
> $ A=(X$Z)
> $ declare -p A
> declare -a A=([0]="Xa" [1]="b")
> I find it surprising that no word splitting is performed in the first
> compound assignment. I realize that skipping word splitting may be
> desirable if a subscript is given (e.g. "A=([0]=$Z)") to make it consistent
> with normal variable assignment[1], but in this case it looks like a bug.

It's an assignment statement in a context where assignment statements are
accepted (which is what makes it different from `echo X=$Z', for instance),
but the lack of a subscript on the lhs makes it a special case. I'll take a
look at the semantics here.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

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