Anonymous | Login | 2024-12-04 06:05 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Type | Date Submitted | Last Update | |||||||
0001876 | [1003.1(2024)/Issue8] Shell and Utilities | Editorial | Clarification Requested | 2024-11-18 23:54 | 2024-11-23 03:32 | |||||||
Reporter | calestyo | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | Open | |||||||||
Status | New | |||||||||||
Name | Christoph Anton Mitterer | |||||||||||
Organization | ||||||||||||
User Reference | ||||||||||||
Section | 2.15 Special Built-In Utilities | |||||||||||
Page Number | 2554 | |||||||||||
Line Number | 83295, ff. | |||||||||||
Interp Status | --- | |||||||||||
Final Accepted Text | ||||||||||||
Summary | 0001876: clarify, whether a trap action that is executed from a context where set -e is ignored, would have set -e ignored, too | |||||||||||
Description |
Hey. I've posted this earlier on the list with no result: https://collaboration.opengroup.org/operational/mailarch.php?soph=N&action=show&archive=austin-group-l&num=37855&limit=100&offset=0&sid= [^] The question is, whether a trap action that is executed while the shell is in a context in which the effects of set -e are ignored, would also cause the same (i.e. ignoring set -e) in the trap action... or whether this is unspecified (than that should be explicitly mentioned). I couldn't find anything in the standard from which I'd say the answer to that question follows. Page 2554, lines 83299-83308 give the exceptions in which set -e is ignored: > 1. The failure of any individual command in a > multi-command pipeline, or of any subshell > environments in which command substitution > was performed during word expansion, shall > not cause the shell to exit. Only the failure > of the pipeline itself shall be considered. > 2. The -e setting shall be ignored when executing > the compound list following the while, until, > if, or elif reserved word, a pipeline > beginning with the ! reserved word, or any > command of an AND-OR list other than the last. > 3. If the exit status of a compound command other > than a subshell command was the result of a > failure while -e was being ignored, then -e > shall not apply to this command. It follows from that, that set -e is ignored on the `false` in the following example: set -e foo() { echo a; false; echo b; } foo || : whereas it is not when just calling: foo Page 2565, lines 83708-83710 say: > The environment in which the shell executes a trap > action on EXIT shall be identical to the environment > immediately after the last command executed before > the trap action on EXIT was executed. From page 2522, line 82167, which says that: > Options turned on at invocation or by set are part of the shell execution environment, one could argue that the whether or not set -e is ignored, applies to an EXIT trap action. One could however also argue that the standard says explicitly that only options turned ON AT INVOCATION or BY SET are part of it, and that the "ignored set -e" behaviour does not really fall under that- For the signals I couldn't find anything about the environment in which the trap action is executed, only page 2521, lines 82148-82153: > When a signal for which a trap has been set is > received while the shell is waiting for the completion > of a utility executing a foreground command, the trap > associated with that signal shall not be executed until > after the foreground command has completed. When the > shell is waiting, by means of the wait utility, for > asynchronous commands to complete, the reception of a > signal for which a trap has been set shall cause the > wait utility to return immediately with an exit > status >128, immediately after which the trap associated > with that signal shall be taken. But that doesn't tell which env. Anyway, some test case seems to imply that at least bash and dash do NOT ignore the effects of set -e, even when the signal is handled at a context where set -e is ignored. set -e foo() { echo a; false; echo b; } trap -- "echo INT; foo" INT sleep 100 || : $ bash t.sh ^CINT a $ dash t.sh ^CINT a $ |
|||||||||||
Desired Action |
Clarify, whether or not any ignoring of set -e would propagate to any trap actions or whether this is unspecified. If it does NOT propagate, one could e.g.: APPEND on page 2554 after line 83319 or after 83308: If any trap action is executed from a context in which set -e is ignored, the effects of that do not propagate into the trap action. If it's unspecified, then at the same position: If any trap action is executed from a context in which set -e is ignored, it is unspecified whether or not the effects of that do propagate into the trap action. Thanks, Chris. |
|||||||||||
Tags | No tags attached. | |||||||||||
Attached Files | ||||||||||||
|
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |