help-bash
[Top][All Lists]
Advanced

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

Re: /dev/fd/63: line 21: ((: takes && kwsi += takes : attempted assignme


From: Alex fxmbsw7 Ratchev
Subject: Re: /dev/fd/63: line 21: ((: takes && kwsi += takes : attempted assignment to non-variable (error token is "+= takes ")
Date: Wed, 9 Feb 2022 21:58:25 +0100

On Wed, Feb 9, 2022 at 9:35 PM Dennis Williamson
<dennistwilliamson@gmail.com> wrote:
>
> On Wed, Feb 9, 2022, 1:52 PM Greg Wooledge <greg@wooledge.org> wrote:
>
> > On Wed, Feb 09, 2022 at 08:20:29PM +0100, Alex fxmbsw7 Ratchev wrote:
> > > bash-5.1# declare -A KWS ; code='echo foo' . ./+kw test ; . ./kws test
> > > bash: ((: takes && kwsi += takes : attempted assignment to
> > > non-variable (error token is "+= takes ")
> >
> > It would be *so* much simpler if you could take the time and effort to
> > construct a minimal reproducing example.  One that people could simply
> > run, without having to jump through *hoops*, to check your results.
> >
> > unicorn:~$ bash-5.1
> > unicorn:~$ takes=
> > unicorn:~$ kwsi=42
> > unicorn:~$ (( takes && kwsi += takes ))
> > bash-5.1: ((: takes && kwsi += takes : attempted assignment to
> > non-variable (error token is "+= takes ")
> >
> > There.  Was that TRULY so difficult that you could not do it yourself?
> >
>
>
> Following up on Greg's excellent advice.
>
> $ (( takes && kwsi += takes ))
> bash-5.1: ((: takes && kwsi += takes : attempted assignment to non-variable
> (error token is "+= takes ")
>
> Hmmm. Something's wrong. What if I further simplify?
>
> (( takes ))
>
> Ok that works. What about
>
> (( kwsi += takes ))
>
> That works too. Maybe it's the &&
>
> (( (takes && kwsi) += takes ))
> ...attempted assignment to non-variable ...
>
> Aha!
>
> (( takes && (kwsi += takes) ))
>
> Bingo! You've solved the problem yourself.

it is so, must learn more



reply via email to

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