[Top][All Lists]

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

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

From: Chris F.A. Johnson
Subject: Re: i++ cause bad return code when result is 1
Date: Mon, 26 Aug 2013 22:06:01 -0400 (EDT)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

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


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

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

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

reply via email to

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