This file is trap.def, from which is created trap.c.
It implements the builtin "trap" in Bash.
-Copyright (C) 1987-2004 Free Software Foundation, Inc.
+Copyright (C) 1987-2005 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
$BUILTIN trap
$FUNCTION trap_builtin
-$SHORT_DOC trap [-lp] [[arg] signal_spec ...]
+$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 (and a single SIGNAL_SPEC
is supplied) or `-', each specified signal is reset to its original
trap_builtin (list)
WORD_LIST *list;
{
- int list_signal_names, display, result, opt;
+ int list_signal_names, display, result, opt, first_signal;
list_signal_names = display = 0;
result = EXECUTION_SUCCESS;
else
{
char *first_arg;
- int operation, sig;
+ int operation, sig, first_signal;
operation = SET;
first_arg = list->word->word;
+ first_signal = first_arg && *first_arg && all_digits (first_arg) && signal_object_p (first_arg, opt);
+
+ /* Backwards compatibility */
+ if (first_signal)
+ operation = REVERT;
/* 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 &&
+ else if (posixly_correct == 0 && first_arg && *first_arg &&
(*first_arg != '-' || first_arg[1]) &&
signal_object_p (first_arg, opt) && list->next == 0)
operation = REVERT;
char *t, *p, *sn;
p = trap_list[i];
-
if (p == (char *)DEFAULT_SIG)
return;