bug-bash
[Top][All Lists]
Advanced

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

Re: i++ cause bad return code when result is 1


From: Greg Wooledge
Subject: Re: i++ cause bad return code when result is 1
Date: Mon, 19 Aug 2013 07:40:06 -0400
User-agent: Mutt/1.4.2.3i

On Mon, Aug 19, 2013 at 05:50:31AM +0200, Chris Down wrote:
> On 2013-08-18 16:57, David Lehmann wrote:
> > The ((i++)) fails only when the result is 1.  When the result is 0 or 2, it
> > does not fail.  This is a problem when 'set -e'.
> 
> This is normal and expected. If the value returned in an (( expression is 
> zero,
> then the exit code is 1. Since you're using a postincrement, zero is returned,
> and then i is incremented to 1.

In fact it's one of my sample cases on http://mywiki.wooledge.org/BashFAQ/105
Note that whether it "works" depends on which version of bash is being used.



reply via email to

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