[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: Sun, 07 Aug 2011 15:03:35 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20100228 Thunderbird/ Mnenhy/

Bob Proulx wrote:
Linda Walsh wrote:
        How about portable code using:

        (exit -1); return

        It's ugly, but would seem to be the portable/official way to
do this.

Exit codes should be in the range 0-255.
        I suppose you don't realize that 'should' is a subjective opinion that
sometimes has little to do with objective reality.

        It is true, that when you display a signed char, non-signed-
-extended, in a 16, 32 or 64 bit format, you see 255, and certainly, no
one (including myself) would suggest 'sign extending' an error code, as that
would make it "other than what it was".  But just because it displays
only as 0-255 under most circumstances is no reason for ignoring the
implementation in all the main languages when the standard was written
as accepting signed short integers.

        The same 'open group' that wrote posix wrote a C standard , and they
defined it's exit val as taking a  short int as well....   So they were

Bash itself is inconsistent in that it accepts exit values the same as every other
program, but limits return values to a particular subset.

reply via email to

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