[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: set -x vs. n=($@)
From: |
Chet Ramey |
Subject: |
Re: set -x vs. n=($@) |
Date: |
Tue, 5 Sep 2023 14:52:28 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 |
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=($@)
It's because the compound assignment forces the expansion to be deferred.
You have to figure out what kind of array you're dealing with, for example,
and what kind of compound assignment, and bash figures all that out after
the `we're performing a variable assignment with xtrace enabled, print the
rhs' code runs.
--
``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/