1 This file is return.def
, from which is created return.c.
2 It implements the builtin
"return" in Bash.
4 Copyright (C
) 1987-2003 Free Software Foundation
, Inc.
6 This file is part of GNU Bash
, the Bourne Again SHell.
8 Bash is free software
; you can redistribute it and
/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation
; either version
2, or (at your option
) any later
13 Bash is distributed in the hope that it will be useful
, but WITHOUT ANY
14 WARRANTY
; without even the implied warranty of MERCHANTABILITY or
15 FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License along
19 with Bash
; see the file COPYING. If not
, write to the Free Software
20 Foundation
, 59 Temple Place
, Suite
330, Boston
, MA
02111 USA.
26 $FUNCTION return_builtin
28 Causes a function to exit with the return value specified by N. If N
29 is omitted
, the return status is that of the last command.
34 #if
defined (HAVE_UNISTD_H
)
36 # include
<sys
/types.h
>
41 #include
"../bashintl.h"
46 extern int last_command_exit_value
;
47 extern int subshell_environment
;
48 extern int return_catch_flag
, return_catch_value
;
50 /* If we are executing a user
-defined function then exit with the value
51 specified as an argument. if no argument is given
, then the last
52 exit status is used.
*/
57 return_catch_value
= get_exitstat (list
);
59 if (return_catch_flag
)
60 longjmp (return_catch
, 1);
63 builtin_error (_("can only `return' from a function or sourced script"));
64 return (EXECUTION_FAILURE
);