[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BASH_COMMAND does not expand correctly in subshells inside traps.
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: BASH_COMMAND does not expand correctly in subshells inside traps. |
Date: |
Fri, 5 Nov 2021 17:14:10 +0100 |
am additional meta data structure
one for saving and restoring traps
one for like is-in-debug-trap
On Fri, Nov 5, 2021, 17:12 Chet Ramey <chet.ramey@case.edu> wrote:
> On 11/4/21 5:49 PM, Emanuele Torre wrote:
>
> > Bash Version: 5.1
> > Patch Level: 8
> > Release Status: release
> >
> > Description:
> > BASH_COMMAND does not expand to the expected value when used in a
> > subshell inside a trap.
>
> This is a variant of
>
> https://lists.gnu.org/archive/html/help-bash/2021-10/msg00269.html
>
> In this case, as explained in the above message, the subshell `forgets'
> that it's executing as part of the DEBUG trap. Since we're not in the
> DEBUG trap, the value of BASH_COMMAND doesn't get updated. As a
> consequence, since the expansion of the command happens in the subshell,
> the original value (unexpanded in the parent shell) remains.
>
> I think I might have to rethink this strategy. What do you think?
>
> Chet
>
> --
> ``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/
>
>