bug-bash
[Top][All Lists]
Advanced

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

Re: set -x vs. n=($@)


From: Dan Jacobson
Subject: Re: set -x vs. n=($@)
Date: Thu, 07 Sep 2023 01:54:41 -0500

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.ramey@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

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