Page MenuHomeFreeBSD

sh.1: Document exit status of the function return command
ClosedPublic

Authored by tembun_bk.ru on Jan 31 2026, 10:40 PM.
Referenced Files
Unknown Object (File)
Sun, Mar 1, 8:13 PM
Unknown Object (File)
Fri, Feb 20, 10:19 AM
Unknown Object (File)
Thu, Feb 19, 12:11 AM
Unknown Object (File)
Wed, Feb 18, 3:47 AM
Unknown Object (File)
Mon, Feb 16, 5:27 PM
Unknown Object (File)
Mon, Feb 16, 4:46 PM
Unknown Object (File)
Mon, Feb 16, 4:22 PM
Unknown Object (File)
Mon, Feb 16, 4:22 PM
Subscribers

Details

Summary

It's not obvious that if exitstatus is omitted, the exit status of the function is taken from the last executed command.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tembun_bk.ru retitled this revision from sh.1: Document exit status for the function return command to sh.1: Document exit status of the function return command.
bin/sh/sh.1
1226–1228

"of the function" seems weird, since the previous sentence says return may also return from a sourced script or shell instance. Perhaps omitting it would suffice?

1229

Manual page style does not use contractions like "it's".

tembun_bk.ru marked 2 inline comments as done.
  • Remove redundant 'of the function' part.
  • Change "it's" -> "it is".

Let's not mention the behaviour when return exits the shell during an EXIT trap action, since it's obscure and probably incorrect (I think it's supposed to work like exit, with a difference between return by itself and return "$?", but in practice it always ignores the argument during an EXIT trap action).

This revision is now accepted and ready to land.Mon, Feb 16, 3:46 PM
This revision was automatically updated to reflect the committed changes.