From a0c0aa41d2ac632529f795a02519b1def00b53cc Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 21 Dec 2019 12:41:03 +0000 Subject: 45111: zshmisc(1): Clarify the documentation of 'return' and 'exit' in conjunction with try/always Having reviewed 20076, 20084, 21734, and 21735, my understanding is that the original intention was: - A 'return' in a function does run always-list - An 'exit' outside a function does not run always-list - A 'return' outside a function is treated as an 'exit' All of which are the case today. The remaining case, of 'exit' used inside a function, was not specified by the referenced -workers@ posts; does, as implemented, run the always-list; and furthermore, based in 21734 it's fair to assume that the original documentation was assuming that 'exit' would be used outside of any function, just like it assumed 'return' would be used inside a function. Therefore, have the documentation specify only the behaviour of 'exit' outside any function, and leave the behaviour of 'exit' inside a function unspecified. Anyone who relied on the documentation of 'exit' as documented until this commit would have run into the documentation/implementation discrepancy described in 45075. --- NEWS | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index c1322ed0f..af59cb4e6 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,16 @@ path the leading '/' counts as one component. The functions builtin gained a -c option to efficiently copy functions. +The zshmisc(1) manual page incorrectly stated that when 'exit' is used +in a `try' block inside a function, the corresponding `always' block will +be executed. The manual page has been corrected. The shell's behaviour +has not changed, but code such as the following: +. + f() { { exit } always { echo Hello world } } +. +should be changed either to use 'return' instead of 'exit', or to have +the try/always block outside of any function. + Changes from 5.6.2 to 5.7.1 --------------------------- -- cgit 1.4.1