[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A typo in Bash manual and how to have a "local" trap instruction
|
From: |
Laurent Lyaudet |
|
Subject: |
Re: A typo in Bash manual and how to have a "local" trap instruction |
|
Date: |
Thu, 19 Mar 2026 16:10:33 +0100 |
Le jeu. 19 mars 2026 Ã 16:02, Laurent Lyaudet
<laurent.lyaudet@gmail.com> a écrit :
>
> Hello :),
>
> I'm trying to make better use of trap builtin.
> I read everything related in the manual,
> and saw this missing closing parenthesis:
> ----------------
> 3.7.6 Signals
> ...
> The trap builtin modifies the shell’s signal handling, as described
> below (see Bourne Shell Builtins.
> ----------------
> I wanted to provide a patch but cloning of bash repository is still ongoing,
> and maybe a patch for a single character would be ridiculous.
>
> Now, my true question: How to have something like a "local" trap
> instruction on RETURN sigspec ?
> I did some testing and the interactive shell RETURN trap is
> overwritten by the one of a shell function.
> How to make both impermeable without using a subshell ?
> Right now, I'm thinking about having a single trapped command on
> RETURN that would be in my code, and that function would handle a
> stack of trap instructions for functions,
> and it would do the work of popping each instruction, executing it, etc.
>
> I hope you may have nice solutions to this problem :).
>
> Best regards,
> Laurent Lyaudet
To expand a bit on what I may do:
declare -a RETURN_TRAP_STACK
RETURN_TRAP_STACK+="${function_name}:${some_instruction}"
etc.