Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug or Feature? Always block triggered by return in subshell within function



Sad! Since their semantics are unspecified, any chance we could bring exit statements in sync (in my opinion the more always block triggered, the better) ? And maybe one day specify their semantics? Or is that deemed too risky because it could break existing scripts? Although, I doubt that many scripts rely on the fact that in this case exit statements do NOT trigger the always block. I would be much more worried about changing return statements to no longer trigger the always block.

Philippe


On Sun, May 11, 2025 at 9:28 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
On Sun, May 11, 2025, at 2:55 PM, Philippe Altherr wrote:
> I find the manual a little confusing because the first sentence
> mentions an exceptional behavior of return and exit statements. Then
> the last sentence states that otherwise return statements work as
> expected but so do exit statements, except if they are directly within
> a subshell. There is actually no explanation of why such exit
> statements don't trigger the always block.

FWIW, the yodl source Doc/Zsh/grammar.yo contains this:

        COMMENT(The semantics of calling 'exit' in try-list inside
        a function are deliberately left unspecified, because
        historically there was a mismatch between the documented and
        implemented behaviours.  Cf. 20076, 21734/21735, 45075.)
        )

https://sourceforge.net/p/zsh/code/ci/zsh-5.9.0.2-test/tree/Doc/Zsh/grammar.yo

Here are the referenced messages in the mailing list archive:

workers/20076: https://www.zsh.org/mla/workers/2004/msg00729.html
workers/21734: https://www.zsh.org/mla/workers/2005/msg01089.html
workers/21735: https://www.zsh.org/mla/workers/2005/msg01090.html
workers/45075: https://www.zsh.org/mla/workers/2019/msg01107.html

--
vq


Messages sorted by: Reverse Date, Date, Thread, Author