is omitted, the return status is that of the last command.
$END
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
#include "../shell.h"
+#include "common.h"
extern int last_command_exit_value;
extern int return_catch_flag, return_catch_value;
-extern jmp_buf return_catch;
/* If we are executing a user-defined function then exit with the value
specified as an argument. if no argument is given, then the last
return_builtin (list)
WORD_LIST *list;
{
- return_catch_value = get_numeric_arg (list);
-
- if (!list)
- return_catch_value = last_command_exit_value;
+ return_catch_value = list ? get_numeric_arg (list) : last_command_exit_value;
if (return_catch_flag)
longjmp (return_catch, 1);
else
{
- builtin_error ("Can only `return' from a function");
+ builtin_error ("can only `return' from a function or sourced script");
return (EXECUTION_FAILURE);
}
}