Date:        Mon, 16 Mar 2020 13:45:28 +0100
    From:        Joerg Schilling <joerg.schill...@fokus.fraunhofer.de>
    Message-ID:  <5e6f74e8.xgypuzg5wdvjbgqk%joerg.schill...@fokus.fraunhofer.de>

  | See my remark about the fact that ksh does not use the same definition of 
  | "return" as POSIX. All shells thatdo not claim ksh compatibilits
  | (which is the majority) do not execute the EXIT trap in that case.

pdksh $ f() ( trap "echo FOO" EXIT; return 5; echo BAR ); f
FOO
mksh $ f() ( trap "echo FOO" EXIT; return 5; echo BAR ); f
FOO
ksh93 $ f() ( trap "echo FOO" EXIT; return 5; echo BAR ); f
FOO
bash$ f() ( trap "echo FOO" EXIT; return 5; echo BAR ); f
FOO
zsh $ f() ( trap "echo FOO" EXIT; return 5; echo BAR ); f
FOO

Now what was it that you were saying ??

The ash derived shells all do the same.   I don't have ksh88 to test.
The same result is achieved if the function is

f() { ( ... ) }

Now, there is no doubt that POSIX does not specify what the "return"
there does.   That was the original issue.   But since all shells we
can find treat that "return" the same as "exit" (however they implement
that) it seems reasonable to specify that.

That an exit trap is not run (eg:

bosh $ f() ( trap "echo FOO" EXIT; return 5; echo BAR ); f
bosh $ 

) when a shell exits, regardless of the cause of the exit,
seems simply to be a bug to me.

kre


Reply via email to