bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debian bug #929178: wrong trap displayed inside functions


From: Chet Ramey
Subject: Re: Debian bug #929178: wrong trap displayed inside functions
Date: Mon, 25 Mar 2024 17:14:26 -0400
User-agent: Mozilla Thunderbird

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    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]