From: Chet Ramey Date: Sat, 3 Dec 2011 17:57:19 +0000 (-0500) Subject: commit bash-20040506 snapshot X-Git-Tag: bash-3.0-rc1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2258e1c964af4baf6398ecb2357fec015c61401;p=thirdparty%2Fbash.git commit bash-20040506 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index f602d06cc..a4eaf3d40 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -9420,3 +9420,32 @@ lib/readline/vi_mode.c of `last', since they're equal at call time and rl_vi_domove can change rl_numeric_arg (which vi apparently updates). Fixes redo bug of `c2....' reported by Marion Berryman + + 5/4 + --- +parse.y + - fix decode_prompt_string to properly deal with strftime() returning 0 + + 5/6 + --- +variables.c + - in make_local_array_variable, return an already-existing local array + variable immediately rather than creating a new array (causing a + memory leak) + + 5/8 + --- +lib/readline/vi_mode.c + - change rl_vi_domove to set rl_explicit_arg before calling + rl_digit_loop1 so that multi-digit numeric arguments work right + - _rl_vi_last_command is no longer static + +lib/readline/rlprivate.h + - new extern declaration for _rl_vi_last_command + +lib/readline/text.c + - change rl_newline to only call _rl_vi_reset_last if the last command + (_rl_vi_last_command) is not a text modification command. This lets + the last-command and last-argument work across command lines + + diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 1cd872e83..df0ad40c0 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -9412,3 +9412,38 @@ builtins/cd.def - if get_working_directory fails and returns null (causing resetpwd to return NULL), use set_working_directory to set $PWD to the absolute pathname for which chdir just succeeded + + 5/1 + --- +lib/readline/vi_mode.c + - in rl_vi_change_to, call _rl_vi_set_last with rl_numeric_arg instead + of `last', since they're equal at call time and rl_vi_domove can + change rl_numeric_arg (which vi apparently updates). Fixes redo bug + of `c2....' reported by Marion Berryman + + 5/4 + --- +parse.y + - fix decode_prompt_string to properly deal with strftime() returning 0 + + 5/6 + --- +variables.c + - in make_local_array_variable, return an already-existing local array + variable immediately rather than creating a new array (causing a + memory leak) + + 5/8 + --- +lib/readline/vi_mode.c + - change rl_vi_domove to set rl_explicit_arg before calling + rl_digit_loop1 so that multi-digit numeric arguments work right + - _rl_vi_last_command is no longer static + +lib/readline/rlprivate.h + - new extern declaration for _rl_vi_last_command + +lib/readline/text.c + - change rl_newline to only call _rl_vi_reset_last if the last command + (_rl_vi_last_command) is not a text modification command + diff --git a/MANIFEST b/MANIFEST index 31666a4cc..121135fe5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -771,6 +771,7 @@ tests/jobs.tests f tests/jobs1.sub f tests/jobs2.sub f tests/jobs3.sub f +tests/jobs4.sub f tests/jobs.right f tests/more-exp.tests f tests/more-exp.right f diff --git a/array.c b/array.c index 9d6358b89..7b0a5d7ba 100644 --- a/array.c +++ b/array.c @@ -9,7 +9,7 @@ * chet@ins.cwru.edu */ -/* Copyright (C) 1997-2002 Free Software Foundation, Inc. +/* Copyright (C) 1997-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. diff --git a/builtins/trap.def b/builtins/trap.def index 70b90fa54..2b3e1b68b 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-2002 Free Software Foundation, Inc. +Copyright (C) 1987-2004 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -121,7 +121,7 @@ trap_builtin (list) operation = SET; first_arg = list->word->word; - /* When not in posix mode, the historical behavior of looking for a + /* 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 && diff --git a/builtins/trap.def~ b/builtins/trap.def~ new file mode 100644 index 000000000..70b90fa54 --- /dev/null +++ b/builtins/trap.def~ @@ -0,0 +1,255 @@ +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. + +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 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. + +$PRODUCES trap.c + +$BUILTIN trap +$FUNCTION trap_builtin +$SHORT_DOC trap [arg] [signal_spec ...] or trap -l +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 +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 $$". +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashtypes.h" +#include +#include +#include "../bashansi.h" + +#include "../shell.h" +#include "../trap.h" +#include "common.h" +#include "bashgetopt.h" + +static void showtrap __P((int)); +static int display_traps __P((WORD_LIST *)); + +/* The trap command: + + trap + trap + trap -l + trap -p [sigspec ...] + trap [--] + + Set things up so that ARG is executed when SIGNAL(s) N is recieved. + If ARG is the empty string, then ignore the SIGNAL(s). If there is + no ARG, then set the trap for SIGNAL(s) to its original value. Just + plain "trap" means to print out the list of commands associated with + each signal number. Single arg of "-l" means list the signal names. */ + +/* Possible operations to perform on the list of signals.*/ +#define SET 0 /* Set this signal to first_arg. */ +#define REVERT 1 /* Revert to this signals original value. */ +#define IGNORE 2 /* Ignore this signal. */ + +extern int posixly_correct; + +int +trap_builtin (list) + WORD_LIST *list; +{ + int list_signal_names, display, result, opt; + + list_signal_names = display = 0; + result = EXECUTION_SUCCESS; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "lp")) != -1) + { + switch (opt) + { + case 'l': + list_signal_names++; + break; + case 'p': + display++; + break; + default: + builtin_usage (); + return (EX_USAGE); + } + } + 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) + return (display_traps (list)); + else + { + char *first_arg; + int operation, sig; + + operation = SET; + first_arg = list->word->word; + /* When not 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)) + operation = REVERT; + else + { + list = list->next; + if (*first_arg == '\0') + operation = IGNORE; + else if (first_arg[0] == '-' && !first_arg[1]) + operation = REVERT; + } + + while (list) + { + sig = decode_signal (list->word->word, opt); + + if (sig == NO_SIG) + { + sh_invalidsig (list->word->word); + result = EXECUTION_FAILURE; + } + else + { + switch (operation) + { + case SET: + set_signal (sig, first_arg); + break; + + case REVERT: + restore_default_signal (sig); + + /* Signals that the shell treats specially need special + handling. */ + switch (sig) + { + case SIGINT: + if (interactive) + set_signal_handler (SIGINT, sigint_sighandler); + else + set_signal_handler (SIGINT, termination_unwind_protect); + break; + + case SIGQUIT: + /* Always ignore SIGQUIT. */ + set_signal_handler (SIGQUIT, SIG_IGN); + break; + case SIGTERM: +#if defined (JOB_CONTROL) + case SIGTTIN: + case SIGTTOU: + case SIGTSTP: +#endif /* JOB_CONTROL */ + if (interactive) + set_signal_handler (sig, SIG_IGN); + break; + } + break; + + case IGNORE: + ignore_signal (sig); + break; + } + } + list = list->next; + } + } + + return (result); +} + +static void +showtrap (i) + int i; +{ + char *t, *p, *sn; + + p = trap_list[i]; + + if (p == (char *)DEFAULT_SIG) + return; + + t = (p == (char *)IGNORE_SIG) ? (char *)NULL : sh_single_quote (p); + sn = signal_name (i); + /* Make sure that signals whose names are unknown (for whatever reason) + are printed as signal numbers. */ + if (STREQN (sn, "SIGJUNK", 7) || STREQN (sn, "unknown", 7)) + printf ("trap -- %s %d\n", t ? t : "''", i); + else if (posixly_correct) + { + if (STREQN (sn, "SIG", 3)) + printf ("trap -- %s %s\n", t ? t : "''", sn+3); + else + printf ("trap -- %s %s\n", t ? t : "''", sn); + } + else + printf ("trap -- %s %s\n", t ? t : "''", sn); + + FREE (t); +} + +static int +display_traps (list) + WORD_LIST *list; +{ + int result, i; + + if (list == 0) + { + for (i = 0; i < BASH_NSIG; i++) + showtrap (i); + return (EXECUTION_SUCCESS); + } + + for (result = EXECUTION_SUCCESS; list; list = list->next) + { + i = decode_signal (list->word->word, DSIG_NOCASE|DSIG_SIGPREFIX); + if (i == NO_SIG) + { + sh_invalidsig (list->word->word); + result = EXECUTION_FAILURE; + } + else + showtrap (i); + } + + return (result); +} diff --git a/doc/bashref.dvi b/doc/bashref.dvi index 32fbaac36..1d5e5ce9e 100644 Binary files a/doc/bashref.dvi and b/doc/bashref.dvi differ diff --git a/doc/bashref.html b/doc/bashref.html index 42fce5d07..c6046ec74 100644 --- a/doc/bashref.html +++ b/doc/bashref.html @@ -1,6 +1,6 @@ - +