[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 5.2.15(1)-release: RETURN trap not executed in cmd subst if last sta
From: |
Chet Ramey |
Subject: |
Re: 5.2.15(1)-release: RETURN trap not executed in cmd subst if last statement of fct is not builtin |
Date: |
Mon, 8 Jul 2024 10:10:35 -0400 |
User-agent: |
Mozilla Thunderbird |
On 7/6/24 7:41 AM, Jens Schmidt wrote:
Today I came across this one:
[copy-on-select-2]$ echo $BASH_VERSION
5.2.15(1)-release
[copy-on-select-2]$ foo() { trap 'echo foo' RETURN; /bin/echo bar; }
[copy-on-select-2]$ foo
bar
foo
[copy-on-select-2]$ baz=$( foo )
[copy-on-select-2]$ echo "<$baz>"
<bar>
I guess that Bash execve's the "/bin/echo" since it runs in a command
substitution and the trap does not get executed, hence.
Thanks for the report. The issue is aggressive fork optimization, as you
suspected.
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/
OpenPGP_signature.asc
Description: OpenPGP digital signature