[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BASH_COMMAND does not expand correctly in subshells inside traps.
From: |
Chet Ramey |
Subject: |
Re: BASH_COMMAND does not expand correctly in subshells inside traps. |
Date: |
Fri, 5 Nov 2021 12:02:03 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 |
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/