My issue is that the resulting behavior in Exercise 1 does not make sense. The resulting value of i should have no bearing on the exit code. If the addition succeeded, the expression should return 0 (success). If i was not an integer (e.g. i=hello), then I expect (( i++ )) to return a non-zero error code.
...IMHO, of course. On Mon, Aug 19, 2013 at 7:40 AM, Greg Wooledge <wool...@eeg.ccf.org> wrote: > 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. >