On 3/25/24 11:45 AM, Gioele Barabucci wrote:
Hi, I'm forwarding a minor issue originally reported in <https://bugs.debian.org/929178>.

If a function does not set a trap, `trap` will output the command set by the caller. This is just a cosmetic issue, the right trap will be run at runtime.

POSIX allows this behavior:

"When a subshell is entered, traps that are not being ignored shall be set
to the default actions, except in the case of a command substitution
containing only a single trap command, when the traps need not be altered.
Implementations may check for this case using only lexical analysis; for
example, if `trap` and $( trap -- ) do not alter the traps in the subshell,
cases such as assigning var=trap and then using $($var) may still alter
them. This does not imply that the trap command cannot be used within the
subshell to set new traps."

and bash implements it. Other shells that aim for POSIX conformance do as
well.


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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to