Re: Regression: EXIT traps always run in global context
From:
Greg Wooledge
Subject:
Re: Regression: EXIT traps always run in global context
Date:
Thu, 28 Nov 2024 08:20:39 -0500
User-agent:
Mutt/1.10.1 (2018-07-13)
On Thu, Nov 28, 2024 at 08:23:48 +0400, Ivan Shapovalov wrote:
> Bash Version: 5.2
> Patch Level: 37
> Release Status: release
>
> Description:
> Regression: When an EXIT trap runs, it runs in global context, i.e.
> does not see the locals defined in the function that was executing
> at the time of the exit.
> Expected behavior in both cases is the same. It was the same until a
> recent bash release.
Perhaps related to this change, introduced in bash 5.2:
f. Fixed a bug that could cause an EXIT trap to use the wrong variable context
when the errexit option is set.
(Your sample script is using set -e.)