[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug: return doesn't accept negative numbers
From: |
Linda Walsh |
Subject: |
Re: bug: return doesn't accept negative numbers |
Date: |
Fri, 05 Aug 2011 18:07:57 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
Linda Walsh wrote:
Seem to fail on any negative number, but 'exit status' is defined
as a short int -- not an unsigned value (i.e. -1 would return 255).
----
Bob Proulx wrote:
Eric Blake wrote:
Linda Walsh wrote:
I guess I don't use negative return codes that often in shell, but
I use them as exit codes reasonably often.
For all of the reasons Eric mentioned you won't ever actually be able
to see a negative result of an exit code however.
----
I never said anything about 'seeing' -1, in fact, I stated just
that -1 would return 255.
return says 'if no args are given' will return exit status of the last
command executed', so
(exit -1);echo $? => 255
(exit -2);echo $? => 254
...
Which is also the way it works in 'C', and perl.
AFAIK, from a compiler perspective, if the value is able to be represented
as a signed-8-bit quantity, conversion is done (i.e. short int becomes
signed char).
Seems that return should handle the same exit values as 'exit'. Isn't
return
supposed to be the 'exit value' of a function?
- bug: return doesn't accept negative numbers, Linda Walsh, 2011/08/05
- Re: bug: return doesn't accept negative numbers, Eric Blake, 2011/08/05
- Re: bug: return doesn't accept negative numbers, Bob Proulx, 2011/08/05
- Re: bug: return doesn't accept negative numbers,
Linda Walsh <=
- Re: bug: return doesn't accept negative numbers, Linda Walsh, 2011/08/07
- Re: bug: return doesn't accept negative numbers, Bob Proulx, 2011/08/07
- Re: bug: return doesn't accept negative numbers, Linda Walsh, 2011/08/08
- Re: bug: return doesn't accept negative numbers, Jon Seymour, 2011/08/11
- Re: bug: return doesn't accept negative numbers, Chet Ramey, 2011/08/07
- Re: bug: return doesn't accept negative numbers, Eric Blake, 2011/08/08