bug-bash
[Top][All Lists]
Advanced

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

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


From: Ilkka Virta
Subject: Re: No word splitting for assignment-like expressions in compound assignment
Date: Tue, 28 Jul 2020 23:14:48 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 28.7. 17:22, Chet Ramey wrote:
On 7/23/20 8:11 PM, Alexey Izbyshev wrote:
$ Z='a b'
$ A=(X=$Z)
$ declare -p A
declare -a A=([0]="X=a b")

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.

This is also a bit curious:

 $ b=( [123]={a,b,c}x )
 $ declare -p b
 declare -a b=([0]="[123]=ax" [1]="[123]=bx" [2]="[123]=cx")

It does seem to have a subscript on the LHS, but it didn't work as one.
To be in line with a plain scalar assignment, the braces should probably not be expanded here.


--
Ilkka Virta / itvirta@iki.fi



reply via email to

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