git: 931d4f0ae4f2 - main - sh.1: Document the exit status of return

From: Alexander Ziaee <ziaee_at_FreeBSD.org>
Date: Mon, 16 Feb 2026 17:24:12 UTC
The branch main has been updated by ziaee:

URL: https://cgit.FreeBSD.org/src/commit/?id=931d4f0ae4f2dcd088bb92459ff19c8b6aafc2cc

commit 931d4f0ae4f2dcd088bb92459ff19c8b6aafc2cc
Author:     Artem Bunichev <tembun@bk.ru>
AuthorDate: 2026-02-16 17:14:00 +0000
Commit:     Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2026-02-16 17:19:40 +0000

    sh.1: Document the exit status of return
    
    It's not obvious that if `exitstatus` is omitted,
    the exit status of the function is taken from the last executed command.
    
    MFC after:              3 days
    Reviewed by:            jilles, ziaee
    Differential Revision:  https://reviews.freebsd.org/D55026
---
 bin/sh/sh.1 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 3113c1cf6166..f4340fab6cdc 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -41,7 +41,7 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"     http://www.opengroup.org/unix/online.html.
 .\"
-.Dd February 3, 2026
+.Dd February 9, 2026
 .Dt SH 1
 .Os
 .Sh NAME
@@ -1223,6 +1223,10 @@ It terminates the current executional scope, returning from the closest
 nested function or sourced script;
 if no function or sourced script is being executed,
 it exits the shell instance.
+If
+.Ar exitstatus
+is specified, the exit status is set to its value,
+otherwise it is set to the exit status of the last executed command.
 The
 .Ic return
 command is implemented as a special built-in command.