1RETURN(P)                  POSIX Programmer's Manual                 RETURN(P)
2
3
4

NAME

6       return - return from a function
7

SYNOPSIS

9       return [n]
10

DESCRIPTION

12       The  return utility shall cause the shell to stop executing the current
13       function or dot script. If the shell is not currently executing a func‐
14       tion or dot script, the results are unspecified.
15

OPTIONS

17       None.
18

OPERANDS

20       See the DESCRIPTION.
21

STDIN

23       Not used.
24

INPUT FILES

26       None.
27

ENVIRONMENT VARIABLES

29       None.
30

ASYNCHRONOUS EVENTS

32       Default.
33

STDOUT

35       Not used.
36

STDERR

38       The standard error shall be used only for diagnostic messages.
39

OUTPUT FILES

41       None.
42

EXTENDED DESCRIPTION

44       None.
45

EXIT STATUS

47       The  value  of the special parameter '?' shall be set to n, an unsigned
48       decimal integer, or to the exit status of the last command executed  if
49       n  is not specified. If the value of n is greater than 255, the results
50       are undefined.  When return is executed in a trap action, the last com‐
51       mand  is considered to be the command that executed immediately preced‐
52       ing the trap action.
53

CONSEQUENCES OF ERRORS

55       Default.
56
57       The following sections are informative.
58

APPLICATION USAGE

60       None.
61

EXAMPLES

63       None.
64

RATIONALE

66       The behavior of return when not in a function  or  dot  script  differs
67       between  the  System  V  shell and the KornShell. In the System V shell
68       this is an error, whereas in the KornShell, the effect is the  same  as
69       exit.
70
71       The  results  of  returning  a  number  greater  than 255 are undefined
72       because of differing practices in the  various  historical  implementa‐
73       tions.  Some  shells AND out all but the low-order 8 bits; others allow
74       larger values, but not of unlimited size.
75
76       See the discussion of appropriate exit status values under exit .
77

FUTURE DIRECTIONS

79       None.
80

SEE ALSO

82       Special Built-In Utilities
83
85       Portions of this text are reprinted and reproduced in  electronic  form
86       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
87       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
88       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
89       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
90       event of any discrepancy between this version and the original IEEE and
91       The Open Group Standard, the original IEEE and The Open Group  Standard
92       is  the  referee document. The original Standard can be obtained online
93       at http://www.opengroup.org/unix/online.html .
94
95
96
97IEEE/The Open Group                  2003                            RETURN(P)
Impressum