Re: [v2 PATCH] trap: Preserve parent traps for trap-only command substitution

Jilles Tjoelker <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
On Mon, Apr 15, 2024 at 06:17:36PM +0800, Herbert Xu wrote:
> v2 restricts the preservation to command substitution only and
> only if the command's first word is "trap".

> ---8<---
> Traps are reset when a subshell is started.  When a subshell is
> started for command substitution with a simple command whose first
> word is "trap", preserve the parent trap text so that they can be
> printed.

It looks like this will execute the EXIT trap in a subshell $(trap).

On the other hand, things like $(trap "echo subshell exit >&2" EXIT) and
$(trap "echo other trap >&2" USR1) seem to be handled correctly.

I think the intent of https://austingroupbugs.net/view.php?id=53 is that
things like $('trap') and $(\trap) should also work (although an
expansion that expands to trap need not work).

-- 
Jilles Tjoelker
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.