[Top][All Lists]

[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: Gecko/20100228 Thunderbird/ Mnenhy/

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?

reply via email to

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