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.