X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fexit.def;h=ee02b38dd119510a4a369291942dc6eac59d999a;hb=d166f048818e10cf3799aa24a174fb22835f1acc;hp=25a3b6332eae67bcfce2921e22770731a9344dfc;hpb=726f63884db0132f01745f1fb4465e6621088ccf;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/exit.def b/builtins/exit.def index 25a3b63..ee02b38 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -1,5 +1,5 @@ This file is exit.def, from which is created exit.c. -It implements the builtins "exit" and "logout" in Bash. +It implements the builtins "exit", and "logout" in Bash. Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. @@ -28,18 +28,28 @@ Exit the shell with a status of N. If N is omitted, the exit status is that of the last command executed. $END +#include + +#include "../bashtypes.h" #include -#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + #include "../shell.h" #include "../jobs.h" +#include "common.h" #include "builtext.h" /* for jobs_builtin */ extern int interactive, login_shell; extern int last_command_exit_value; +extern Function *this_shell_builtin; +extern Function *last_shell_builtin; static int exit_or_logout (); -static int sourced_logout = 0; +static int sourced_logout; int exit_builtin (list) @@ -65,19 +75,15 @@ int logout_builtin (list) WORD_LIST *list; { - if (!login_shell && interactive) + if (login_shell == 0 && interactive) { - builtin_error ("Not login shell: use `exit'"); + builtin_error ("not login shell: use `exit'"); return (EXECUTION_FAILURE); } else return (exit_or_logout (list)); } -/* Clean up work for exiting or logging out. */ -Function *last_shell_builtin = (Function *)NULL; -Function *this_shell_builtin = (Function *)NULL; - static int exit_or_logout (list) WORD_LIST *list; @@ -87,7 +93,7 @@ exit_or_logout (list) #if defined (JOB_CONTROL) int exit_immediate_okay; - exit_immediate_okay = (!interactive || + exit_immediate_okay = (interactive == 0 || last_shell_builtin == exit_builtin || last_shell_builtin == logout_builtin || last_shell_builtin == jobs_builtin); @@ -97,7 +103,7 @@ exit_or_logout (list) { register int i; for (i = 0; i < job_slots; i++) - if (jobs[i] && (jobs[i]->state == JSTOPPED)) + if (jobs[i] && STOPPED (i)) { fprintf (stderr, "There are stopped jobs.\n"); @@ -113,17 +119,20 @@ exit_or_logout (list) /* Get return value if present. This means that you can type `logout 5' to a shell, and it returns 5. */ - if (list) - exit_value = get_numeric_arg (list); - else - exit_value = last_command_exit_value; + exit_value = list ? get_numeric_arg (list, 1) : last_command_exit_value; /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */ if (login_shell && sourced_logout++ == 0) - maybe_execute_file ("~/.bash_logout", 1); + { + maybe_execute_file ("~/.bash_logout", 1); +#ifdef SYS_BASH_LOGOUT + maybe_execute_file (SYS_BASH_LOGOUT, 1); +#endif + } last_command_exit_value = exit_value; /* Exit the program. */ - longjmp (top_level, EXITPROG); + jump_to_top_level (EXITPROG); + /*NOTREACHED*/ }