3 2

Handling of builtin exit status

Details
Message ID
<20190326011032.GC825@homura.localdomain>
DKIM signature
pass
Download raw message
Most builtins return EXIT_SUCCESS or EXIT_FAILURE. However, the POSIX
specification explicitly refers to status codes as 0 or >0, as well as
occasionally specifying status codes of specific values like 126 or 127.
On a system where EXIT_SUCCESS != 0 or EXIT_FAILURE == 0, mrsh would not
be POSIX-compatible.

I think we ought to ditch EXIT_SUCCESS and EXIT_FAILURE in favor of
explicit status codes throughout. Thoughts?

-- 
Drew DeVault
Details
Message ID
<F8Z_M47DYTSMRB3AAhdE0FwXNDRn2E3RoHlam207nALSAWv1C7WtNq_urjXwaX4oc0FFCOHUy1jlzt4cfn9DN8SA3sdDEA3kQTGxNz6yKMo=@emersion.fr>
In-Reply-To
<20190326011032.GC825@homura.localdomain> (view parent)
DKIM signature
pass
Download raw message
On Tuesday, March 26, 2019 3:10 AM, Drew DeVault <sir@cmpwn.com> wrote:
> Most builtins return EXIT_SUCCESS or EXIT_FAILURE. However, the POSIX
> specification explicitly refers to status codes as 0 or >0, as well as
>
> occasionally specifying status codes of specific values like 126 or 127.
> On a system where EXIT_SUCCESS != 0 or EXIT_FAILURE == 0, mrsh would not
> be POSIX-compatible.
>
> I think we ought to ditch EXIT_SUCCESS and EXIT_FAILURE in favor of
> explicit status codes throughout. Thoughts?

EXIT_SUCCESS is defined as:

> Successful termination for exit(); evaluates to 0.

and EXIT_FAILURE as:

> Unsuccessful termination for exit(); evaluates to a non-zero value.

(source: [1])

So we should be fine (and at least POSIX is consistent). I agree EXIT_*
constants aren't terribly useful. The only case in which they might be
is to make it clear a return value is an exit code.

POSIX also specifies more specific exit codes in some special cases,
and we should make sure we are compliant in this regard (I think that's
an item in the mrsh status issue).

[1]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdlib.h.html
Details
Message ID
<20190328232739.GE25618@homura.localdomain>
In-Reply-To
<F8Z_M47DYTSMRB3AAhdE0FwXNDRn2E3RoHlam207nALSAWv1C7WtNq_urjXwaX4oc0FFCOHUy1jlzt4cfn9DN8SA3sdDEA3kQTGxNz6yKMo=@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
Since we have to use specific numbered exit codes in some places, would
you advocate a mixed approach, using EXIT_* when appropriate, and
integers when necessary, or using only integers?
Details
Message ID
<sXf-S6zeCmGfodHZkTfxJ6TYVsuEME6R2oNQDCK5x5liVQI0uPXeJqdHe2bajjEr7piBXY7hY2EOApQkL9e2s2QyDzS4ZxytDdyIlHsvwEM=@emersion.fr>
In-Reply-To
<20190328232739.GE25618@homura.localdomain> (view parent)
DKIM signature
pass
Download raw message
On Friday, March 29, 2019 1:27 AM, Drew DeVault <sir@cmpwn.com> wrote:
> Since we have to use specific numbered exit codes in some places, would
> you advocate a mixed approach, using EXIT_* when appropriate, and
> integers when necessary, or using only integers?

I'm not feeling strongly about this, but maybe we should drop EXIT_*
altogether.