[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Dumb question about variable increment
From: |
John Kearney |
Subject: |
Re: [Help-bash] Dumb question about variable increment |
Date: |
Thu, 3 Mar 2016 16:22:39 +0100 |
() puts it in a subshell
try
UPDATED=0
false || { true && : $((UPDATED+=1)) ; }
On Thu, Mar 3, 2016 at 3:27 PM, Florent B <address@hidden> wrote:
> Hi everyone,
>
> I got a little problem with variable increment in a bash script.
>
> I want to increment a variable when a command succeed.
>
> Here is a sample script :
>
> UPDATED=0
> false || ( true && ((UPDATED++)) )
>
> Why does my variable UPDATED does not increment ?
>
> If I run :
>
> false || ( true && echo "It works" )
>
> "It works" is printed, so why UPDATED is not incremented ?
>
> I can't find my problem...
>
> Thank you.
>
> Florent
>
- Re: [Help-bash] Dumb question about variable increment,
John Kearney <=