bug-bash
[Top][All Lists]
Advanced

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

Re: return exit code in EXIT trap


From: Chet Ramey
Subject: Re: return exit code in EXIT trap
Date: Mon, 8 Aug 2022 10:34:50 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 8/6/22 12:05 AM, Robert Elz wrote:
I am actually astounded by all of this - both by what is in the
standard, and the way Chet interpreted it.

The language in the standard for return was clearly based upon the
idea that it should act just the same as exit, which is not really
appropriate.

It's a logical conclusion from the requirement that the trap action be
executed as if you had dropped an `eval action' into the function, or
wherever the shell is executing when the trap is processed.


Return is nothing like that - it isn't even
clear that it is specified (not even when the trap fires when a function is
running) that a return in the trap handler can do any more then cause the
function it is lexically defined within to return (which does not mean the
function that happened to be running at the time).   That to me looks
unspecified (in at least the latest wording).

The requirement that it be equivalent to `eval action' whenever it's
executed seems like it has some pretty specific implications.

The language in POSIX is clearly broken, and needs fixing.  What's kind of
amazing is that none of the "primary" austin group people made any responses
at all to the mailing list discussion.

Clearly this needs a posix defect report filed, if no-one else does that
today, I probably will.

Please do. The behavior is all over the place, and it seems like every
shell has exceptions to

"The value of "$?" after the trap action completes shall be the value it
had before trap was invoked."

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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