Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001425 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Objection Error 2020-11-23 23:10 2020-11-23 23:10
Reporter kre View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Robert Elz
Organization
User Reference
Section XCU 2.14 / exit
Page Number 2399
Line Number 76764-5
Interp Status ---
Final Accepted Text
Summary 0001425: exit in an EXIT trap is not clearly specified
Description the page for the special builtin command "exit" says

    A trap on EXIT shall be executed before the shell terminates,
    except when the exit utility is invoked in that trap itself,
    in which case the shell shall exit immediately.

The issue is what "that trap itself" means.

Consider

   $SHELL -c 'trap "trap \"echo bar\" EXIT; echo foo; exit" EXIT'

When the exit command in the outer exit trap is executed, the EXIT
trap has been changed to be something different, that is, the
shell is not executing the (current) EXIT trap when that exit command
is executed, so by a literal reading of the standard, the inner trap
should fire, and the shell should print

    foo
    bar

before exiting.

That is what the FreeBSD and NetBSD shells, and bosh, mksh, and zsh do.
bash yash ksh93 and dash print only "foo", that is they seem to ignore
the "that" in "that exit trap" and treat the text as if it said

    except when the exit utility is invoked in an exit trap

The page in XCU 2.14 for trap says nothing pertinent to this issue
(I am not suggesting that it should, just noting it).
Desired Action Since the "reference" shells seem to do this the broken way, it is
unlikely that the standard will have words (or an example) added to
reinforce the current wording (I am guessing).

But since the other shells are doing exactly what the standard requires
of them, it would be incorrect, and unfair to specify this so as to
require the currently non-standard behaviour that the reference shells
implement.

Given that, the best that can be done, I believe, is to add a new
sentence, immediately after the one quoted above (which is unchanged
in 202x drafts) something like

    It is unspecified whether an EXIT trap defined while executing
    a previous EXIT trap will be executed before the shell terminates
    after completing execution (via an exit command, or reaching the
    end) of the earlier EXIT trao.

Tags No tags attached.
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2020-11-23 23:10 kre New Issue
2020-11-23 23:10 kre Name => Robert Elz
2020-11-23 23:10 kre Section => XCU 2.14 / exit
2020-11-23 23:10 kre Page Number => 2399
2020-11-23 23:10 kre Line Number => 76764-5


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker