summaryrefslogtreecommitdiff
path: root/builtins/trap.def
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2004-11-09 21:37:25 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:57 +0000
commiteb87367179effbe5f430236db8259006d71438b7 (patch)
tree012cd9de789fea49510f8e25118acf2be9bfa2ed /builtins/trap.def
parentb80f6443b6b7b620c7272664c66ecb0b120a0998 (diff)
downloadbash-eb87367179effbe5f430236db8259006d71438b7.tar.gz
Imported from ../bash-3.0.16.tar.gz.
Diffstat (limited to 'builtins/trap.def')
-rw-r--r--builtins/trap.def13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtins/trap.def b/builtins/trap.def
index 9dd746fb..1ecbfbdb 100644
--- a/builtins/trap.def
+++ b/builtins/trap.def
@@ -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;