[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
The following issue has a resolution that has been APPLIED. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: Applied Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text:http://austingroupbugs.net/view.php?id=1211#c4355 Resolution: Accepted As Marked Fixed in Version: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2019-11-12 15:40 UTC == Summary:"trap" (with no args) specification does not match reality == Relationships ID Summary -- related to 0001212 Enhance trap command == Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 2018-09-28 09:04 geoffclare Note Edited: 0004133 2018-09-28 09:05 geoffclare Note Deleted: 0004134 2018-09-28 10:25 kreNote Added: 0004135 2018-09-28 10:40 kreNote Added: 0004136 2019-04-04 16:36 geoffclare Note Added: 0004355 2019-04-04 16:38 geoffclare Interp Status => --- 2019-04-04 16:38 geoffclare Final Accepted Text => http://austingroupbugs.net/view.php?id=1211#c4355 2019-04-04 16:38 geoffclare Status New => Resolved 2019-04-04 16:38 geoffclare Resolution Open => Accepted As Marked 2019-04-04 16:38 geoffclare Tag Attached: tc3-2008 2019-04-09 11:19 geoffclare Relationship added related to 0001212 2019-11-12 15:40 geoffclare Status Resolved => Applied ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
The following issue has been set as RELATED TO issue 0001212. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: Resolved Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text:http://austingroupbugs.net/view.php?id=1211#c4355 Resolution: Accepted As Marked Fixed in Version: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2019-04-04 16:38 UTC == Summary:"trap" (with no args) specification does not match reality == Relationships ID Summary -- related to 0001212 Enhance trap command == Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 2018-09-28 09:04 geoffclare Note Edited: 0004133 2018-09-28 09:05 geoffclare Note Deleted: 0004134 2018-09-28 10:25 kreNote Added: 0004135 2018-09-28 10:40 kreNote Added: 0004136 2019-04-04 16:36 geoffclare Note Added: 0004355 2019-04-04 16:38 geoffclare Interp Status => --- 2019-04-04 16:38 geoffclare Final Accepted Text => http://austingroupbugs.net/view.php?id=1211#c4355 2019-04-04 16:38 geoffclare Status New => Resolved 2019-04-04 16:38 geoffclare Resolution Open => Accepted As Marked 2019-04-04 16:38 geoffclare Tag Attached: tc3-2008 2019-04-09 11:19 geoffclare Relationship added related to 0001212 ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
The following issue has been RESOLVED. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: Resolved Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text:http://austingroupbugs.net/view.php?id=1211#c4355 Resolution: Accepted As Marked Fixed in Version: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2019-04-04 16:38 UTC == Summary:"trap" (with no args) specification does not match reality == Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 2018-09-28 09:04 geoffclare Note Edited: 0004133 2018-09-28 09:05 geoffclare Note Deleted: 0004134 2018-09-28 10:25 kreNote Added: 0004135 2018-09-28 10:40 kreNote Added: 0004136 2019-04-04 16:36 geoffclare Note Added: 0004355 2019-04-04 16:38 geoffclare Interp Status => --- 2019-04-04 16:38 geoffclare Final Accepted Text => http://austingroupbugs.net/view.php?id=1211#c4355 2019-04-04 16:38 geoffclare Status New => Resolved 2019-04-04 16:38 geoffclare Resolution Open => Accepted As Marked ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
A NOTE has been added to this issue. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2019-04-04 16:36 UTC == Summary:"trap" (with no args) specification does not match reality == -- (0004355) geoffclare (manager) - 2019-04-04 16:36 http://austingroupbugs.net/view.php?id=1211#c4355 -- Change the sentence starting on line 77514 from:The trap command with no operands shall write to standard output a list of commands associated with each condition.to:The trap command with no operands shall write to standard output a list of commands associated with each condition which is not in its default state. Change the sentence at line 77522 from:The shell shall format the output, including the proper use of quoting, so that it is suitable for reinput to the shell as commands that achieve the same trapping results.to:The shell shall format the output, including the proper use of quoting, so that it is suitable for reinput to the shell as commands that achieve the same trapping results for those traps that had previously been altered. And also change the example at lines 77524-6 from:save_traps=$(trap) ... eval "$save_traps"to:save_traps=$(trap) trap "some command" INT QUIT save_traps="trap - INT QUIT; $save_traps" ... eval "$save_traps" On page 2422 line 77564, change APPLICATION USAGE from:None.to:Since trap with no operands does not output commands to restore traps that are currently set to default, these need to be restored separately. The DESCRIPTION section shows one example, but the method it uses relies on hard-coding the commands to reset the traps that are being set. A more general approach would be: save_traps=$(trap) ... for sig in EXIT $( kill -l ) do case "$sig" in SIGKILL | KILL | sigkill | kill | SIGSTOP | STOP | sigstop | stop) ;; *) trap - $sig ;; esac done eval "$save_traps" However, this has a race condition since it first sets all traps (that can be set) to default and then restores those that were not previously set to default. On page 2423, line 77606 (FUTURE DIRECTIONS) change:None.to:A future version of this standard may define a mechanism to obtain the current setting of all traps (including those in their default state). Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 2018-09-28 09:04 geoffclare Note Edited: 0004133 2018-09-28 09:05 geoffclare Note Deleted: 0004134 2018-09-28 10:25 kreNote Added: 0004135 2018-09-28 10:40 kreNote Added: 0004136 2019-04-04 16:36
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
A NOTE has been added to this issue. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2018-09-28 10:40 UTC == Summary:"trap" (with no args) specification does not match reality == -- (0004136) kre (reporter) - 2018-09-28 10:40 http://austingroupbugs.net/view.php?id=1211#c4136 -- I just realised that I left messed up one of the desired changes in the Desired action. The paragraph that begins ... Change the sentence at line 77522 from should have the text that is currently there, followed by "to" (that is, what looks to be intended to be the old text, is in fact the desired new text...) Also, wwrt general solutions, if the standard had "trap -" to reset all traps to their defaults, workaround would be easier. This may actually exist in more shells than have trap -p, but I haven't tested it. If we could rely upon that, a workable solution to this problem would be easier. Do note though that any solution that resets traps to default, and then puts them back to their old values suffers from races, when a signal arrives between the "trap - xxx" (or just "trap -" and when the eval "$saved_traps" is done, so while they can often be used as a "good enough" solution, we really do need (eventually) to add something which really works. Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 2018-09-28 09:04 geoffclare Note Edited: 0004133 2018-09-28 09:05 geoffclare Note Deleted: 0004134 2018-09-28 10:25 kreNote Added: 0004135 2018-09-28 10:40 kreNote Added: 0004136 ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
A NOTE has been added to this issue. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2018-09-28 10:25 UTC == Summary:"trap" (with no args) specification does not match reality == -- (0004135) kre (reporter) - 2018-09-28 10:25 http://austingroupbugs.net/view.php?id=1211#c4135 -- First, what is most important here is that it is recognised that the current wording is inadequate, and promises something that it is unable to deliver. The workaround method that can be used can vary, I'm sure there are many possibilities - your scheme (note 4133) assumes you know in advance what traps are to be altered, which will often be the case, but is not suitable for a general solution. Regardless of that, we need to do something to make it clear that simply using $(trap) is not sufficient in any current shell as a method of restoring what was there before. Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 2018-09-28 09:04 geoffclare Note Edited: 0004133 2018-09-28 09:05 geoffclare Note Deleted: 0004134 2018-09-28 10:25 kreNote Added: 0004135 ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
A NOTE has been added to this issue. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2018-09-28 08:53 UTC == Summary:"trap" (with no args) specification does not match reality == -- (0004134) geoffclare (manager) - 2018-09-28 08:53 http://austingroupbugs.net/view.php?id=1211#c4134 -- Sorry I missed the bit where you said "Shells only list traps that have been altered from the default". Please ignore http://austingroupbugs.net/view.php?id=1211#c4133. Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 2018-09-28 08:53 geoffclare Note Added: 0004134 ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
A NOTE has been added to this issue. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2018-09-28 08:44 UTC == Summary:"trap" (with no args) specification does not match reality == -- (0004133) geoffclare (manager) - 2018-09-28 08:44 http://austingroupbugs.net/view.php?id=1211#c4133 -- The reason your test script produces no output is because you haven't set any traps! $ ksh -c 'trap foo INT; x=$(trap); echo "$x"' trap -- foo INT $ bash -c 'trap foo INT; x=$(trap); echo "$x"' trap -- 'foo' INT This issue was investigated in depth in 2009 via http://austingroupbugs.net/view.php?id=53 Do I have your permission to close this new bug as withdrawn? Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 2018-09-28 08:44 geoffclare Note Added: 0004133 ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
A NOTE has been added to this issue. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2018-09-28 03:23 UTC == Summary:"trap" (with no args) specification does not match reality == -- (0004132) kre (reporter) - 2018-09-28 03:23 http://austingroupbugs.net/view.php?id=1211#c4132 -- In the description, the "echo $x" should obviously be "echo $X" (or it should be x= instead of X= ... that's a transcription error, it makes no difference to the result. Issue History Date ModifiedUsername FieldChange == 2018-09-28 02:22 kreNew Issue 2018-09-28 02:22 kreName => Robert Elz 2018-09-28 02:22 kreSection => XCU 2.14 -- trap special builtin 2018-09-28 02:22 krePage Number => 2420 2018-09-28 02:22 kreLine Number => 77514 - 77526 2018-09-28 03:20 kreTag Attached: tc3-2008 2018-09-28 03:20 kreTag Attached: issue8 2018-09-28 03:20 kreTag Detached: tc3-2008 2018-09-28 03:21 kreTag Detached: issue8 2018-09-28 03:23 kreNote Added: 0004132 ==
[1003.1(2016)/Issue7+TC2 0001211]: "trap" (with no args) specification does not match reality
The following issue has been SUBMITTED. == http://austingroupbugs.net/view.php?id=1211 == Reported By:kre Assigned To: == Project:1003.1(2016)/Issue7+TC2 Issue ID: 1211 Category: Shell and Utilities Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Robert Elz Organization: User Reference: Section:XCU 2.14 -- trap special builtin Page Number:2420 Line Number:77514 - 77526 Interp Status: --- Final Accepted Text: == Date Submitted: 2018-09-28 02:22 UTC Last Modified: 2018-09-28 02:22 UTC == Summary:"trap" (with no args) specification does not match reality Description: I kind of brlieve I have seen this somewhere before, but cannot find it if it exists already, if so, and if this contains nothing new,just close it... The trap command description states: The trap command with no operands shall write to standard output a list of commands associated with each condition. If the command is executed [ what follows is not relevant to the issue in question ] Otherwise, the list shall contain the commands currently associated with each condition. [ then follows the format to be used, also not relevant here ] The shell shall format the output, including the proper use of quoting, [ not relevant here, but let's keep that bit ] so that it is suitable for reinput to the shell as commands that achieve the same trapping results. For example: save_traps=$(trap) ... eval "$save_traps" If only it were so, but there neither is, nor ever has been, a shell that acts like that. for f in sh yash zsh bash mksh fbsh bosh ksh mksh dash do echo "$f: $( $f -c 'X=$(trap); echo "$x"' )" done | sort bash: bosh: dash: fbsh: ksh: mksh: mksh: sh: yash: zsh: (the "sort" is just because I couldn't be bothered to generate the list in a sane order...) sh is NetBSD, fbsh is FreeBSD, ksh is pdksh (right now I do not have access to ksh93, but it acts the same.) Shells only list traps that have been altered from the default in the output from the "trap" command.This makes it useless for the intended effect, as if a piece of code does saved_traps=$(trap) trap '' INT # do some code with SIGINT ignored (that works fine) eval "${saved_traps}" then one would expect, from the wording in the standard, that after the eval, the action for SIGINT would be back to what it was when the saved_traps= line was executed.In *every* existing shell that happens only when an INT trap had been set before this code (of if it had been ignored, but then it would not be interesting). I will be submitting an enhancement request as a separate issue to actually provide a mechanism that does work, but that isn't appropriate here, the best we can to for tc8 is to correct this wording so it is not nonsense... (however nice it would be if the nonsense were reality.) Desired Action: Change the sentence starting on line 77514 from The trap command with no operands shall write to standard output a list of commands associated with each condition. to The trap command with no operands shall write to standard output a list of commands associated with each condition which is not in its default state. Change the sentence at line 77522 from The shell shall format the output, including the proper use of quoting, so that it is suitable for reinput to the shell as commands that achieve the same trapping results for those traps that had previously been altered. And also change the example at lines 77524-6 from save_traps=$(trap) ... eval "$save_traps" to save_traps=$(trap) ... for sig in EXIT $( kill -l ) do case "$sig" in SIGKILL | KILL | sigkill | kill | SIGSTOP | STOP | sigstop | stop) ;; *) trap - $sig ;; esac done eval "$save_traps" (and don't add these words, but yes, that is absurd, there needs to be a better way, but pretending that it works as is, or that shells will ever be altered to make the current description work, is not it) On page 2423, line 77606 (FUTURE DIRECTIONS) change None. to A mechanism to obtain the current setting of all traps