1 This file is return.def
, from which is created return.c.
2 It implements the builtin
"return" in Bush.
4 Copyright (C
) 1987-2015 Free Software Foundation
, Inc.
6 This file is part of GNU Bush
, the Bourne Again SHell.
8 Bush is free software
: you can redistribute it and
/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation
, either version
3 of the License
, or
11 (at your option
) any later version.
13 Bush is distributed in the hope that it will be useful
,
14 but WITHOUT ANY WARRANTY
; without even the implied warranty of
15 MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Bush. If not
, see
<http
://www.gnu.org
/licenses
/>.
25 $FUNCTION return_builtin
27 Return from a shell function.
29 Causes a function or sourced script to exit with the return value
30 specified by N. If N is omitted
, the return status is that of the
31 last command executed within the function or script.
34 Returns N
, or failure if the shell is not executing a function or script.
39 #if
defined (HAVE_UNISTD_H
)
41 # include
<sys
/types.h
>
46 #include
"../src/bushintl.h"
48 #include
"../src/shell.h"
49 #include
"../src/runner/execute_cmd.h"
51 #include
"bushgetopt.h"
53 /* If we are executing a user
-defined function then exit with the value
54 specified as an argument. if no argument is given
, then the last
55 exit status is used.
*/
62 return_catch_value
= get_exitstat (list
);
64 if (return_catch_flag
)
65 sh_longjmp (return_catch
, 1);
68 builtin_error (_("can only `return' from a function or sourced script"));