|Anonymous | Login||2021-01-16 05:22 UTC|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details|
|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|
|Section||XCU 2.14 / exit|
|Final Accepted Text|
|Summary||0001425: exit in an EXIT trap is not clearly specified|
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.
$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
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).
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
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.|
|There are no notes attached to this issue.|
|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|