Imported from ../bash-4.0-rc1.tar.gz.
This commit is contained in:
parent
f1be666c7d
commit
3185942a52
666 changed files with 188710 additions and 54674 deletions
|
@ -1,30 +1,31 @@
|
|||
This file is exit.def, from which is created exit.c.
|
||||
It implements the builtins "exit", and "logout" in Bash.
|
||||
|
||||
Copyright (C) 1987-2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2, or (at your option) any later
|
||||
version.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
Bash is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES exit.c
|
||||
|
||||
$BUILTIN exit
|
||||
$FUNCTION exit_builtin
|
||||
$SHORT_DOC exit [n]
|
||||
Exit the shell with a status of N. If N is omitted, the exit status
|
||||
Exit the shell.
|
||||
|
||||
Exits the shell with a status of N. If N is omitted, the exit status
|
||||
is that of the last command executed.
|
||||
$END
|
||||
|
||||
|
@ -45,6 +46,7 @@ $END
|
|||
#include "common.h"
|
||||
#include "builtext.h" /* for jobs_builtin */
|
||||
|
||||
extern int check_jobs_at_exit;
|
||||
extern int last_command_exit_value;
|
||||
extern int running_trap, trap_saved_exit_value;
|
||||
extern int subshell_environment;
|
||||
|
@ -60,7 +62,7 @@ exit_builtin (list)
|
|||
{
|
||||
if (interactive)
|
||||
{
|
||||
fprintf (stderr, login_shell ? "logout\n" : "exit\n");
|
||||
fprintf (stderr, login_shell ? _("logout\n") : "exit\n");
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
|
@ -69,8 +71,11 @@ exit_builtin (list)
|
|||
|
||||
$BUILTIN logout
|
||||
$FUNCTION logout_builtin
|
||||
$SHORT_DOC logout
|
||||
Logout of a login shell.
|
||||
$SHORT_DOC logout [n]
|
||||
Exit a login shell.
|
||||
|
||||
Exits a login shell with exit status N. Returns an error if not executed
|
||||
in a login shell.
|
||||
$END
|
||||
|
||||
/* How to logout. */
|
||||
|
@ -94,7 +99,7 @@ exit_or_logout (list)
|
|||
int exit_value;
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
int exit_immediate_okay;
|
||||
int exit_immediate_okay, stopmsg;
|
||||
|
||||
exit_immediate_okay = (interactive == 0 ||
|
||||
last_shell_builtin == exit_builtin ||
|
||||
|
@ -102,21 +107,32 @@ exit_or_logout (list)
|
|||
last_shell_builtin == jobs_builtin);
|
||||
|
||||
/* Check for stopped jobs if the user wants to. */
|
||||
if (!exit_immediate_okay)
|
||||
if (exit_immediate_okay == 0)
|
||||
{
|
||||
register int i;
|
||||
for (i = 0; i < js.j_jobslots; i++)
|
||||
for (i = stopmsg = 0; i < js.j_jobslots; i++)
|
||||
if (jobs[i] && STOPPED (i))
|
||||
{
|
||||
fprintf (stderr, _("There are stopped jobs.\n"));
|
||||
stopmsg = JSTOPPED;
|
||||
else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
|
||||
stopmsg = JRUNNING;
|
||||
|
||||
/* This is NOT superfluous because EOF can get here without
|
||||
going through the command parser. Set both last and this
|
||||
so that either `exit', `logout', or ^D will work to exit
|
||||
immediately if nothing intervenes. */
|
||||
this_shell_builtin = last_shell_builtin = exit_builtin;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
if (stopmsg == JSTOPPED)
|
||||
fprintf (stderr, _("There are stopped jobs.\n"));
|
||||
else if (stopmsg == JRUNNING)
|
||||
fprintf (stderr, _("There are running jobs.\n"));
|
||||
|
||||
if (stopmsg && check_jobs_at_exit)
|
||||
list_all_jobs (JLIST_STANDARD);
|
||||
|
||||
if (stopmsg)
|
||||
{
|
||||
/* This is NOT superfluous because EOF can get here without
|
||||
going through the command parser. Set both last and this
|
||||
so that either `exit', `logout', or ^D will work to exit
|
||||
immediately if nothing intervenes. */
|
||||
this_shell_builtin = last_shell_builtin = exit_builtin;
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue