OK. That's well and good. But my main problem now is that that fact is
not documented anywhere.

(Also here it is again, so as to remove any confusion about "compound
assignment" (some readers might think it meant two ='s on the same line.)

$ bash -c 'set a b c; set -x; m=$@; n=($@)'
+ m='a b c'
+ n=($@)

)
>>>>> "CR" == Chet Ramey <chet.ra...@case.edu> writes:
CR> On 9/3/23 6:08 AM, Dan Jacobson wrote:
>> It's not fair:
>> set -x a b c
>> m=$@ n=($@)
>> == gives ==
>> + m='a b c'
>> + n=($@)

CR> It's because the compound assignment forces the expansion to be deferred.
CR> You have to figure out what kind of array you're dealing with, for example,
CR> and what kind of compound assignment, and bash figures all that out after
CR> the `we're performing a variable assignment with xtrace enabled, print the
CR> rhs' code runs.

Reply via email to