On Tue, 27 Aug 2013, Chris Down wrote:

On 2013-08-26 21:36, David Lehmann wrote:
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.

That would be pretty much rewriting the entire way that (( works, since the
whole point is that it returns a status based upon having a return value that
is >0.

   Rather, that it is != 0

Compare:

   $ (( 0 )); echo "$?"
   1
   $ (( 1 )); echo "$?"
   0

$ (( -1 )); echo "$?"
0

--
   Chris F.A. Johnson, <http://cfajohnson.com/>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Reply via email to