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

2023-09-07 Thread Dan Jacobson
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'

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

2023-09-05 Thread Chet Ramey
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

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

2023-09-05 Thread Chet Ramey
On 9/3/23 12:15 PM, Lawrence Velázquez wrote: However... bash-5.2$ declare -a c=("$a") + c=('foo') + declare -a c You kind of have to. This isn't an assignment statement, since `declare' is a builtin and its arguments have to be expanded before it's called and set -x

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

2023-09-03 Thread alex xmb ratchev
On Sun, Sep 3, 2023, 20:57 Greg Wooledge wrote: > On Sun, Sep 03, 2023 at 08:39:25PM +0200, alex xmb ratchev wrote: > > On Sun, Sep 3, 2023, 12:08 Dan Jacobson wrote: > > > > > It's not fair: > > > set -x a b c > > > > > > > you may want -v > > *Sigh* No. set -v shows lines as they are being

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

2023-09-03 Thread Greg Wooledge
On Sun, Sep 03, 2023 at 08:39:25PM +0200, alex xmb ratchev wrote: > On Sun, Sep 3, 2023, 12:08 Dan Jacobson wrote: > > > It's not fair: > > set -x a b c > > > > you may want -v *Sigh* No. set -v shows lines as they are being READ by the shell. set -x shows commands as they are being EXECUTED.

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

2023-09-03 Thread alex xmb ratchev
On Sun, Sep 3, 2023, 12:08 Dan Jacobson wrote: > It's not fair: > set -x a b c > you may want -v m=$@ n=($@) > == gives == > + m='a b c' > + n=($@) > please either say > + m=$@ > + n=($@) > or better: > + m='a b c' > + n=('a' 'b' 'c') > or metion on >

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

2023-09-03 Thread Lawrence Velázquez
On Sun, Sep 3, 2023, at 6:08 AM, Dan Jacobson wrote: > please either say > + m=$@ > + n=($@) > or better: > + m='a b c' > + n=('a' 'b' 'c') > or metion on > https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html > the special exception. This behavior is not specific to $@.

set -x vs. n=($@)

2023-09-03 Thread Dan Jacobson
It's not fair: set -x a b c m=$@ n=($@) == gives == + m='a b c' + n=($@) please either say + m=$@ + n=($@) or better: + m='a b c' + n=('a' 'b' 'c') or metion on https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html the special exception. GNU bash, version 5.2.15