Imported from ../bash-3.0.tar.gz.
This commit is contained in:
parent
7117c2d221
commit
b80f6443b6
400 changed files with 69247 additions and 13346 deletions
|
@ -1,7 +1,7 @@
|
|||
This file is trap.def, from which is created trap.c.
|
||||
It implements the builtin "trap" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2004 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
@ -23,20 +23,21 @@ $PRODUCES trap.c
|
|||
|
||||
$BUILTIN trap
|
||||
$FUNCTION trap_builtin
|
||||
$SHORT_DOC trap [arg] [signal_spec ...] or trap -l
|
||||
$SHORT_DOC trap [-lp] [[arg] signal_spec ...]
|
||||
The command ARG is to be read and executed when the shell receives
|
||||
signal(s) SIGNAL_SPEC. If ARG is absent all specified signals are
|
||||
reset to their original values. If ARG is the null string each
|
||||
SIGNAL_SPEC is ignored by the shell and by the commands it invokes.
|
||||
If a SIGNAL_SPEC is EXIT (0) the command ARG is executed on exit from
|
||||
the shell. If a SIGNAL_SPEC is DEBUG, ARG is executed after every
|
||||
command. If ARG is `-p' then the trap commands associated with
|
||||
each SIGNAL_SPEC are displayed. If no arguments are supplied or if
|
||||
only `-p' is given, trap prints the list of commands associated with
|
||||
each signal number. Each SIGNAL_SPEC is either a signal name in <signal.h>
|
||||
or a signal number. `trap -l' prints a list of signal names and their
|
||||
corresponding numbers. Note that a signal can be sent to the shell
|
||||
with "kill -signal $$".
|
||||
signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC
|
||||
is supplied) or `-', each specified signal is reset to its original
|
||||
value. If ARG is the null string each SIGNAL_SPEC is ignored by the
|
||||
shell and by the commands it invokes. If a SIGNAL_SPEC is EXIT (0)
|
||||
the command ARG is executed on exit from the shell. If a SIGNAL_SPEC
|
||||
is DEBUG, ARG is executed after every simple command. If the`-p' option
|
||||
is supplied then the trap commands associated with each SIGNAL_SPEC are
|
||||
displayed. If no arguments are supplied or if only `-p' is given, trap
|
||||
prints the list of commands associated with each signal. Each SIGNAL_SPEC
|
||||
is either a signal name in <signal.h> or a signal number. Signal names
|
||||
are case insensitive and the SIG prefix is optional. `trap -l' prints
|
||||
a list of signal names and their corresponding numbers. Note that a
|
||||
signal can be sent to the shell with "kill -signal $$".
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
@ -108,6 +109,8 @@ trap_builtin (list)
|
|||
}
|
||||
list = loptend;
|
||||
|
||||
opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */
|
||||
|
||||
if (list_signal_names)
|
||||
return (display_signal_list ((WORD_LIST *)NULL, 1));
|
||||
else if (display || list == 0)
|
||||
|
@ -119,13 +122,22 @@ trap_builtin (list)
|
|||
|
||||
operation = SET;
|
||||
first_arg = list->word->word;
|
||||
if (first_arg && *first_arg && (*first_arg != '-' || first_arg[1]) &&
|
||||
signal_object_p (first_arg))
|
||||
/* When in posix mode, the historical behavior of looking for a
|
||||
missing first argument is disabled. To revert to the original
|
||||
signal handling disposition, use `-' as the first argument. */
|
||||
if (posixly_correct == 0 && first_arg && *first_arg &&
|
||||
(*first_arg != '-' || first_arg[1]) &&
|
||||
signal_object_p (first_arg, opt) && list->next == 0)
|
||||
operation = REVERT;
|
||||
else
|
||||
{
|
||||
list = list->next;
|
||||
if (*first_arg == '\0')
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
else if (*first_arg == '\0')
|
||||
operation = IGNORE;
|
||||
else if (first_arg[0] == '-' && !first_arg[1])
|
||||
operation = REVERT;
|
||||
|
@ -133,7 +145,7 @@ trap_builtin (list)
|
|||
|
||||
while (list)
|
||||
{
|
||||
sig = decode_signal (list->word->word);
|
||||
sig = decode_signal (list->word->word, opt);
|
||||
|
||||
if (sig == NO_SIG)
|
||||
{
|
||||
|
@ -235,7 +247,7 @@ display_traps (list)
|
|||
|
||||
for (result = EXECUTION_SUCCESS; list; list = list->next)
|
||||
{
|
||||
i = decode_signal (list->word->word);
|
||||
i = decode_signal (list->word->word, DSIG_NOCASE|DSIG_SIGPREFIX);
|
||||
if (i == NO_SIG)
|
||||
{
|
||||
sh_invalidsig (list->word->word);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue