From 08cee6879c28b5f4761050f12a3ec2b22544df62 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 16 Apr 2021 18:04:13 +0000 Subject: [PATCH 4/5] docs: return: Give examples of using arithmetic evaluation. --- Doc/Zsh/builtins.yo | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 264ee9484..640cfb674 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1626,9 +1626,15 @@ cindex(functions, returning from) item(tt(return) [ var(n) ])( Causes a shell function or `tt(.)' script to return to the invoking script with the return status specified by -an arithmetic expression var(n). If var(n) +an arithmetic expression var(n). +For example, the following prints `tt(42)': + +example(() { integer foo=40; return "foo + 2" } +echo $?) + +If var(n) is omitted, the return status is that of the last command -executed. +executed. If tt(return) was executed from a trap in a tt(TRAP)var(NAL) function, the effect is different for zero and non-zero return status. With zero @@ -1637,7 +1643,7 @@ will return to whatever it was previously processing; with a non-zero status, the shell will behave as interrupted except that the return status of the trap is retained. Note that the numeric value of the signal which caused the trap is passed as the first argument, so the statement -`tt(return $((128PLUS()$1)))' will return the same status as if the signal +`tt(return "128PLUS()$1")' will return the same status as if the signal had not been trapped. ) module(sched)(zsh/sched)