exit trap defined in function body isn't triggered
From:
Oğuz
Subject:
exit trap defined in function body isn't triggered
Date:
Mon, 30 Mar 2020 21:45:48 +0300
Consider this:
bash <<EOF
foo() {
trap 'echo exit' EXIT
}
foo &
EOF
After trap is set, the subshell exits and `echo exit` should be run,
but it won't. If you set a RETURN trap instead it works though. This
is reproducible on bash4 and bash5
--
Oğuz