help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Dumb question about variable increment


From: Greg Wooledge
Subject: Re: [Help-bash] Dumb question about variable increment
Date: Thu, 3 Mar 2016 10:24:35 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Mar 03, 2016 at 03:27:41PM +0100, Florent B wrote:
>     UPDATED=0
>     false || ( true && ((UPDATED++)) )
> 
> Why does my variable UPDATED does not increment ?

It does, but the increment takes place in the subshell that you explicitly
requested by putting parentheses around true && ((UPDATED++)).

Parentheses create a subshell.  If you simply wanted a command grouping,
use curly braces:

false || { true && ((UPDATED++)); }

This one doesn't create a subshell.



reply via email to

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