Thank You Thorsten,

I hoped, it would be obvious that this is a bug and mksh could be fixed.
It is strange, that mksh lets me define an exit trap without error, but then ignores the trap.
But things seem not to be so easy.

I think the use case of the "subshell_exit" is obvious.
But I will describe it in one sentence, to explain, why I think this bug matters.
The use case: If a subshell does something, that requires a temporary file,
it should also define an EXIT trap, to make sure the temporary file is deleted,
if the script ends unexpected.

The problem is, I see no easy workaround.
So this means for me, I will not support mksh in my library.

If you think this bug does not help to improve mksh, it's probably the best if you close the bug.

Thank you for your help. You have also added some other shells to your tests, that I did not try before.
And I will try to support some of those shells instead of mksh.

Regards
Bernd


Zitat von Thorsten Glaser <t...@mirbsd.de>:

Bernd Schumacher dixit:

Please confirm, that this is a bug and not the expected behaviour of mksh.

I still cannot confirm either way, but some preliminary research
with an extended test script:

$ cat script
fkt()
{
  trap -- "echo $1 >&2" EXIT
}
fkt shell_exit
$(fkt fn_exit)
$(trap -- "echo comsub_exit >&2" EXIT)
(trap -- "echo subshell_exit >&2" EXIT)

$ mksh script
shell_exit

$ bash2.05b script
subshell_exit
shell_exit

$ ksh93 script
fn_exit
comsub_exit
subshell_exit
shell_exit

$ bash4 script
fn_exit
comsub_exit
subshell_exit
shell_exit

$ nbsh script
fn_exit
comsub_exit
subshell_exit
shell_exit

$ dash script
fn_exit
comsub_exit
subshell_exit
shell_exit

$ yash script
fn_exit
comsub_exit
subshell_exit
shell_exit

$ zsh script
shell_exit
fn_exit
comsub_exit
subshell_exit

$ zsh --emulate sh script
fn_exit
comsub_exit
subshell_exit
shell_exit


With the addition of subshell_exit (I renamed yours in fn_exit),
itbWEXa85mzq8jbnryA/pFY+Hg6ijpLzEuKeht
mr/glldKR5/ELai4yRSYW+BemnR+b2lBhOOeWOfB2RooEc0rkBP+LOsjZ6x99AE/
X/z20pj+uMHiVn7AGpdZorvCqp2GpTfLwZbFsnuKxOtVQZQklDe6hk9Fsuyn155B
Z+ESS8i84yyUEQj5CNRwviPuAQ3wnXXAqcPEthIhkXrnwi2IRpWujYjWWB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