Page MenuHomeFreeBSD

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

Authored by temcbun_gmail.com on Jan 31 2026, 10:40 PM.
Referenced Files
Unknown Object (File)
Wed, Jun 17, 5:50 AM
Unknown Object (File)
Wed, Jun 17, 5:12 AM
Unknown Object (File)
Sat, Jun 13, 11:06 AM
Unknown Object (File)
Sat, Jun 13, 2:49 AM
Unknown Object (File)
Sat, Jun 13, 1:04 AM
Unknown Object (File)
Fri, Jun 12, 11:15 PM
Unknown Object (File)
Fri, Jun 12, 6:06 PM
Unknown Object (File)
Wed, Jun 10, 5:53 AM
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 Skipped
Unit
Tests Skipped

Event Timeline

temcbun_gmail.com 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".

temcbun_gmail.com 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.Feb 16 2026, 3:46 PM
This revision was automatically updated to reflect the committed changes.