aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bunichev <tembun@bk.ru>2026-02-16 17:14:00 +0000
committerAlexander Ziaee <ziaee@FreeBSD.org>2026-02-16 17:19:40 +0000
commit931d4f0ae4f2dcd088bb92459ff19c8b6aafc2cc (patch)
tree36932458264b6ddf67db37690f5e9cb94d7cb24c
parentf1f142c01db43c7dc8d0d172fc1726da2ee01972 (diff)
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
-rw-r--r--bin/sh/sh.16
1 files changed, 5 insertions, 1 deletions
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.