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'
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
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
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
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.
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
>
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 $@.
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