From 97d4bdbc7e86e6e8da0d4a059b118ffab289d3a9 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 24 Aug 2017 19:46:20 +0100 Subject: 41590 modified as 41595: make ERR_RETURN more logical. It now operates separately at each function depth. To keep ERR_EXIT global, make the noerrexit variable usd bit flags. Extend tests. --- Doc/Zsh/options.yo | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'Doc/Zsh/options.yo') diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 70092d681..42571fccd 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -1659,6 +1659,13 @@ as it is by default, and the option tt(ERR_EXIT) is found to have been set on exit, then the command for which the tt(DEBUG) trap is being executed is skipped. The option is restored after the trap exits. +Non-zero status in a command list containing tt(&&) or tt(||) is ignored +for commands not at the end of the list. Hence + +example(false && true) + +does not trigger exit. + Exiting due to tt(ERR_EXIT) has certain interactions with asynchronous jobs noted in ifzman(the section JOBS in zmanref(zshmisc))\ @@ -1672,10 +1679,25 @@ cindex(function return, on error) cindex(return from function, on error) item(tt(ERR_RETURN))( If a command has a non-zero exit status, return immediately from the -enclosing function. The logic is identical to that for tt(ERR_EXIT), +enclosing function. The logic is similar to that for tt(ERR_EXIT), except that an implicit tt(return) statement is executed instead of an tt(exit). This will trigger an exit at the outermost level of a non-interactive script. + +Normally this option inherits the behaviour of tt(ERR_EXIT) that +code followed by `tt(&&)' `tt(||)' does not trigger a return. Hence +in the following: + +example(summit || true) + +no return is forced as the combined effect always has a zero return +status. + +Note. however, that if tt(summit) in the above example is itself a +function, code inside it is considered separately: it may force a return +from tt(summit) (assuming the option remains set within tt(summit)), but +not from the enclosing context. This behaviour is different from +tt(ERR_EXIT) which is unaffected by function scope. ) pindex(EVAL_LINENO) pindex(NO_EVAL_LINENO) -- cgit 1.4.1