RETURN(1P)

๐Ÿ’– RETURN(1P) โ€” the POSIX Programmer's Manual glow-up ๐Ÿ’–

okay bestie, buckle up, we're doing return(1P) from the POSIX Programmer's Manual โœจ


๐ŸŒธ PROLOG ๐ŸŒธ

okay so real talk first: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the tea on Linux behavior, iykyk), or honestly the interface may not be implemented on Linux at all. ๐Ÿ™ˆ


๐Ÿ‘‘ NAME ๐Ÿ‘‘

return โ€” return from a function or dot script


โœจ SYNOPSIS โœจ

return [n]

๐Ÿ’… DESCRIPTION ๐Ÿ’…

The return utility shall cause the shell to stop executing the current function or dot script. That's it, that's the whole vibe. ๐ŸŽ€

But listen โ€” if the shell is not currently executing a function or dot script, the results are unspecified. No cap. So don't come crying to me when it does something feral. ๐Ÿ˜ญ


๐Ÿฆ‹ OPTIONS ๐Ÿฆ‹

None. Not a single one. She's minimal, she's clean, she's iconic. โœจ


๐Ÿ“ OPERANDS ๐Ÿ“

See the DESCRIPTION. (Yeah I know, they just pointed at the other section. Rude but valid. ๐Ÿ’€)


๐ŸŒˆ STDIN ๐ŸŒˆ

Not used. She does not read. She is not taking input today. ๐Ÿ™…โ€โ™€๏ธ


๐Ÿงš INPUT FILES ๐Ÿงš

None. Zero. Nada. ๐ŸŽ€


๐Ÿ’œ ENVIRONMENT VARIABLES ๐Ÿ’œ

None. She does not care about your environment, bestie. She's above it. ๐Ÿ‘‘


โญ ASYNCHRONOUS EVENTS โญ

Default. โœจ


๐ŸŒธ STDOUT ๐ŸŒธ

Not used. She's not printing anything, she's leaving. ๐Ÿ’…


๐Ÿ’– STDERR ๐Ÿ’–

The standard error shall be used only for diagnostic messages. So if something shows up there, it's a warning, not a vibe. ๐Ÿซถ


๐ŸŽ€ OUTPUT FILES ๐ŸŽ€

None. ๐Ÿฆ‹


๐Ÿ”ฅ EXTENDED DESCRIPTION ๐Ÿ”ฅ

None. (The extended description is giving "no thoughts, head empty" and honestly? respect.) โœจ


๐Ÿ‘‘ EXIT STATUS ๐Ÿ‘‘

okay this is the part that actually matters so pay attention bestie:

  • The value of the special parameter '?' shall be set to n, an unsigned decimal integer โ€” or to the exit status of the last command executed if n is not specified.
  • If n is not an unsigned decimal integer, or is greater than 255, the results are unspecified. ๐Ÿšจ like, undefined. chaos. do not do this.
  • When return is executed in a trap action, the last command is considered to be the command that executed immediately preceding the trap action. (yes, that's the exact rule, write it down ๐Ÿ“)

๐Ÿ’€ CONSEQUENCES OF ERRORS ๐Ÿ’€

Default. โœจ

The following sections are informative. (so like, they're the lore, not the law ๐Ÿ“–)


๐ŸŒˆ APPLICATION USAGE ๐ŸŒˆ

None. Nothing to add, she said what she said. ๐Ÿ’…


๐Ÿ“ EXAMPLES ๐Ÿ“

None. The examples section is empty and honestly it's giving mysterious main character energy. ๐Ÿ™ˆ


๐Ÿง  RATIONALE ๐Ÿง 

okay so the drama:

The behavior of return when not in a function or dot script differs between the System V shell and the KornShell. In the System V shell this is an error, whereas in the KornShell, the effect is the same as exit. So like... two shells, two completely different personalities. ๐Ÿ˜ญ

The results of returning a number greater than 255 are undefined because of differing practices in the various historical implementations. Some shells AND out all but the low-order 8 bits; others allow larger values, but not of unlimited size. (yes, "AND" is literally the word they used, it's bitwise AND, we love a retro moment ๐Ÿ’–)

See the discussion of appropriate exit status values under exit. ๐Ÿ‘€


๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

None. The future is hers and she's not changing a thing. ๐Ÿ‘‘


๐Ÿ“š SEE ALSO ๐Ÿ“š

  • Section 2.9.5, Function Definition Command
  • Section 2.14, Special Built-In Utilities
  • dot

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


fr fr, that's the whole page. every flag (there are none ๐Ÿ’€), every operand, every status, every warning โ€” all accounted for. no details were harmed in the making of this glow-up. ๐Ÿซถ

and that's a wrap, bestie โ€” this one came to you courtesy of IEEE/The Open Group, 2017, on the RETURN(1P) page. slay, bye ๐Ÿ’…โœจ๐ŸŽ€๐Ÿฆ‹๐Ÿ’–

๐Ÿ“ฆ where this page comes from