bug-bash
[Top][All Lists]
Advanced

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

Re: ++ causes 2 variables to increment


From: phil colbourn
Subject: Re: ++ causes 2 variables to increment
Date: Tue, 17 May 2016 20:00:10 +0100

Thanks Grisha,

Sorry for putting you through analysing my faulty example.




Phil

On 16 May 2016 at 05:58, Grisha Levit <address@hidden> wrote:

On Sun, May 15, 2016 at 4:42 PM, phil colbourn <address@hidden> wrote:
> # here, M=2

It's not -- the value of $M here is the string "F[word]".  Your print function reports the value of "$((M*1))", which is, in fact "2": inside the arithmetic _expression_ "M" is expanded to "F[word]" which is expanded to "2".

# without changing M, it is now 3!!!!!!

Exactly, M does not change, it is still "F[word]".  But since F[word] changes, the value of $((M*1)) does change to reflect the new value of F[word].

Instead of M=F[$W], I think you want to be doing M=${F[$W]}.


reply via email to

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