X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Ftrap.def;h=669bea7a49756a82d93087e4e56c9c91e14e9d11;hb=95732b497d12c98613bb3c5db16b61f377501a59;hp=9dd746fbaf81e8d0069100517ec59244bc7ad12a;hpb=b80f6443b6b7b620c7272664c66ecb0b120a0998;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/trap.def b/builtins/trap.def index 9dd746f..669bea7 100644 --- a/builtins/trap.def +++ b/builtins/trap.def @@ -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-2004 Free Software Foundation, Inc. +Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -23,7 +23,7 @@ $PRODUCES trap.c $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 @@ -87,7 +87,7 @@ int 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; @@ -118,14 +118,19 @@ trap_builtin (list) 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; @@ -209,7 +214,6 @@ showtrap (i) char *t, *p, *sn; p = trap_list[i]; - if (p == (char *)DEFAULT_SIG) return;