]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20041202 snapshot
authorChet Ramey <chet.ramey@case.edu>
Sat, 3 Dec 2011 18:40:44 +0000 (13:40 -0500)
committerChet Ramey <chet.ramey@case.edu>
Sat, 3 Dec 2011 18:40:44 +0000 (13:40 -0500)
CWRU/CWRU.chlog
doc/bash.1
doc/bashref.texi
doc/version.texi
execute_cmd.c
lib/glob/xmbsrtowcs.c
lib/readline/misc.c
tests/RUN-ONE-TEST
trap.c

index 40b29b08398533c22897dbf3960cbaef5305c633..dd4bf49e690cecb858b622210b354fccf65cfb3b 100644 (file)
@@ -10644,3 +10644,33 @@ execute_cmd.c
 trap.c
        - change reset_or_restore_signal_handlers so that the RETURN trap is
          not inherited by command substitution when DEBUGGER is not defined
+
+                                  11/30
+                                  -----
+lib/readline/misc.c
+       - fix memory leaks in _rl_free_history_entry and rl_maybe_replace_line
+         caused by not freeing `timestamp' member of history entry
+       - make sure timestamp is initialized to NULL in rl_maybe_save_line
+
+                                  12/1
+                                  ----
+execute_cmd.c
+       - fix execute_function so a function calling `return' will run the
+         RETURN trap, if one's defined
+
+doc/{bash.1,bashref.texi}
+       - fix description of RETURN trap in various places to indicate that it's
+         only inherited by shell functions if function tracing is on globally
+         or has been enabled for that function
+       - fix documentation to indicate that the DEBUG and RETURN traps are
+         inherited under the same conditions
+
+execute_cmd.c
+       - a function does not inherit the RETURN trap if a DEBUG trap is
+         currently running
+
+                                  12/2
+                                  ----
+lib/glob/xmbsrtowcs.c
+       - change xmbsrtowcs to handle the one case where malloc can fail
+         (though it should not matter) -- don't try to free a null pointer
index 29f9a3860c4bdfd88add7d3b8d40663f580930f1..544b85c5abcd61a447db34801c7b36d557ca60d2 100644 (file)
@@ -6,12 +6,12 @@
 .\"    Case Western Reserve University
 .\"    chet@po.CWRU.Edu
 .\"
-.\"    Last Change: Mon Nov 22 11:06:21 EST 2004
+.\"    Last Change: Wed Dec  1 15:39:20 EST 2004
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2004 Nov 22" "GNU Bash-3.1-devel"
+.TH BASH 1 "2004 Dec 1" "GNU Bash-3.1-devel"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -3320,19 +3320,21 @@ environment are identical between a function and its caller
 with the exception that the
 .SM
 .B DEBUG
-trap (see the description of the
+and
+.B RETURN
+traps (see the description of the
 .B trap
 builtin under
 .SM
 .B SHELL BUILTIN COMMANDS
-below) is not inherited unless the function has been given the
+below) are not inherited unless the function has been given the
 \fBtrace\fP attribute (see the description of the
 .SM
 .B declare
 builtin below) or the
 \fB\-o functrace\fP shell option has been enabled with
 the \fBset\fP builtin
-(in which case all functions inherit the \fBDEBUG\fP trap).
+(in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps).
 .PP
 Variables local to the function may be declared with the
 .B local
@@ -6424,7 +6426,8 @@ by subsequent assignment statements or unset.
 .TP
 .B \-t
 Give each \fIname\fP the \fItrace\fP attribute.
-Traced functions inherit the \fBDEBUG\fP trap from the calling shell.
+Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
+the calling shell.
 The trace attribute has no special meaning for variables.
 .TP
 .B \-x
@@ -7773,9 +7776,11 @@ follows the logical chain of directories when performing commands
 which change the current directory.
 .TP 8
 .B \-T
-If set, any trap on \fBDEBUG\fP is inherited by shell functions, command
-substitutions, and commands executed in a subshell environment.
-The \fBDEBUG\fP trap is normally not inherited in such cases.
+If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
+functions, command substitutions, and commands executed in a
+subshell environment.
+The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
+in such cases.
 .TP 8
 .B \-\-
 If no arguments follow this option, then the positional parameters are
index b1b014dbee82d484739a1aca7f66e4c098af80fb..81dd4945ff99ea7a3f34c85894233e7a8ff8d7c5 100644 (file)
@@ -1118,12 +1118,12 @@ The first element of the @env{FUNCNAME} variable is set to the
 name of the function while the function is executing.
 All other aspects of the shell execution
 environment are identical between a function and its caller
-with the exception that the @env{DEBUG} trap
-below) is not inherited unless the function has been given the
+with the exception that the @env{DEBUG} and @env{RETURN} traps
+are not inherited unless the function has been given the
 @code{trace} attribute using the @code{declare} builtin or
 the @code{-o functrace} option has been enabled with
 the @code{set} builtin,
-(in which case all functions inherit the @code{DEBUG} trap).
+(in which case all functions inherit the @env{DEBUG} and @env{RETURN} traps).
 @xref{Bourne Shell Builtins}, for the description of the
 @code{trap} builtin.
 
@@ -3283,7 +3283,8 @@ by subsequent assignment statements or unset.
 
 @item -t
 Give each @var{name} the @code{trace} attribute.
-Traced functions inherit the @code{DEBUG} trap from the calling shell.
+Traced functions inherit the @code{DEBUG} and @code{RETURN} traps from
+the calling shell.
 The trace attribute has no special meaning for variables.
 
 @item -x
@@ -4126,9 +4127,11 @@ $ cd ..; pwd
 @end example
 
 @item -T
-If set, any trap on @code{DEBUG} is inherited by shell functions, command
-substitutions, and commands executed in a subshell environment.
-The @code{DEBUG} trap is normally not inherited in such cases.
+If set, any trap on @code{DEBUG} and @code{RETURN} are inherited by
+shell functions, command substitutions, and commands executed
+in a subshell environment.
+The @code{DEBUG} and @code{RETURN} traps are normally not inherited
+in such cases.
 
 @item --
 If no arguments follow this option, then the positional parameters are
@@ -7184,7 +7187,9 @@ The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
 Commands specified with an @code{RETURN} trap are executed before
 execution resumes after a shell function or a shell script executed with
 @code{.} or @code{source} returns.
-The @code{RETURN} trap is not inherited by shell functions.
+The @code{RETURN} trap is not inherited by shell functions unless the
+function has been given the @code{trace} attribute or the
+@code{functrace} option has been enabled using the @code{shopt} builtin.
 
 @item
 The Bash @code{type} builtin is more extensive and gives more information
index 9aef4ca7a5a8c65e88b33c93dea1caedf5077314..804df1f118ddd9219fd3c807a8f28c091d274c6e 100644 (file)
@@ -2,9 +2,9 @@
 Copyright (C) 1988-2004 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Wed Nov 24 14:11:51 EST 2004
+@set LASTCHANGE Wed Dec  1 15:39:35 EST 2004
 
 @set EDITION 3.1-devel
 @set VERSION 3.1-devel
-@set UPDATED 24 November 2004
-@set UPDATED-MONTH November 2004
+@set UPDATED 1 December 2004
+@set UPDATED-MONTH December 2004
index 69f18855800015f3284016f06f1acb78998089ab..4824175df000c9cc06cf0f260deb5d1e35af3d6a 100644 (file)
@@ -2741,35 +2741,20 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
 
   if (dofork)
     {
-#if 0
-      /* XXX memory leak if expand_words() error causes a jump_to_top_level */
-      command_line = savestring (the_printed_command);
-#endif
-
       /* Do this now, because execute_disk_command will do it anyway in the
         vast majority of cases. */
       maybe_make_export_env ();
 
-#if 0
-      if (make_child (command_line, async) == 0)
-#else
       if (make_child (savestring (the_printed_command), async) == 0)
-#endif
        {
          already_forked = 1;
          simple_command->flags |= CMD_NO_FORK;
 
-#if 0
-         subshell_environment = (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
-                                       ? (SUBSHELL_PIPE|SUBSHELL_FORK)
-                                       : (SUBSHELL_ASYNC|SUBSHELL_FORK);
-#else
          subshell_environment = SUBSHELL_FORK;
          if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
            subshell_environment |= SUBSHELL_PIPE;
          if (async)
            subshell_environment |= SUBSHELL_ASYNC;
-#endif
 
          /* We need to do this before piping to handle some really
             pathological cases where one of the pipe file descriptors
@@ -3187,7 +3172,13 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
       restore_default_signal (ERROR_TRAP);
     }
 
+  /* Shell functions inherit the RETURN trap if function tracing is on
+     globally or on individually for this function. */
+#if 0
   if (return_trap && ((trace_p (var) == 0) && function_trace_mode == 0))
+#else
+  if (return_trap && (signal_in_progress (DEBUG_TRAP) || ((trace_p (var) == 0) && function_trace_mode == 0)))
+#endif
     {
       if (subshell == 0)
        {
@@ -3242,14 +3233,10 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
   if (return_val)
     {
       result = return_catch_value;
-#if 0
-      /* Run the RETURN trap in the function's context.  XXX - have to talk
-        to Rocky about why his bashdb code doesn't have `return' run the
-        RETURN trap. */
+      /* Run the RETURN trap in the function's context. */
       save_current = currently_executing_command;
       run_return_trap ();
       currently_executing_command = save_current;
-#endif
     }
   else
     {
index f1703bccf99b7f8b3594b57697b07b2c507c0761..f8c29b915cbaeb08f83984e69d208ec96ec352e8 100644 (file)
@@ -1,6 +1,6 @@
 /* xmbsrtowcs.c -- replacement function for mbsrtowcs */
 
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2004 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -54,7 +54,7 @@ xmbsrtowcs (dest, src, len, pstate)
       ps = &local_state;
     }
 
-  n = strlen(*src);
+  n = strlen (*src);
 
   if (dest == NULL)
     {
@@ -62,19 +62,22 @@ xmbsrtowcs (dest, src, len, pstate)
       const char *mbs;
       mbstate_t psbuf;
 
+      /* It doesn't matter if malloc fails here, since mbsrtowcs should do
+        the right thing with a NULL first argument. */
       wsbuf = (wchar_t *) malloc ((n + 1) * sizeof(wchar_t));
       mbs = *src;
       psbuf = *ps;
 
       wclength = mbsrtowcs (wsbuf, &mbs, n, &psbuf);
 
-      free (wsbuf);
+      if (wsbuf)
+       free (wsbuf);
       return wclength;
     }
       
   for (wclength = 0; wclength < len; wclength++, dest++)
     {
-      if(mbsinit(ps))
+      if (mbsinit(ps))
        {
          if (**src == '\0')
            {
@@ -166,10 +169,11 @@ xdupmbstowcs (destp, indicesp, src)
 
   p = src;
   wcnum = 0;
-  do {
+  do
+    {
       size_t mblength; /* Byte length of one multibyte character. */
 
-      if(mbsinit (&state))
+      if (mbsinit (&state))
        {
          if (*p == '\0')
            {
@@ -230,7 +234,8 @@ xdupmbstowcs (destp, indicesp, src)
       wsbuf[wcnum - 1] = wc;
       indices[wcnum - 1] = (char *)p;
       p += mblength;
-  } while (MB_NULLWCH (wc) == 0);
+    }
+  while (MB_NULLWCH (wc) == 0);
 
   /* Return the length of the wide character string, not including `\0'. */
   *destp = wsbuf;
index 403313a04350f29e561f2423a88b4e104c03f03b..5054358d12cd04974396fe1964be7f716bda32df 100644 (file)
@@ -225,8 +225,10 @@ _rl_free_history_entry (entry)
 {
   if (entry == 0)
     return;
-  if (entry->line)
-    free (entry->line);
+
+  FREE (entry->line);
+  FREE (entry->timestamp);
+
   free (entry);
 }
 
@@ -242,6 +244,7 @@ rl_maybe_replace_line ()
     {
       temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
       free (temp->line);
+      FREE (temp->timestamp);
       free (temp);
     }
   return 0;
@@ -274,6 +277,7 @@ rl_maybe_save_line ()
     {
       _rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
       _rl_saved_line_for_history->line = savestring (rl_line_buffer);
+      _rl_saved_line_for_history->timestamp = (char *)NULL;
       _rl_saved_line_for_history->data = (char *)rl_undo_list;
     }
 
index 72ec06a2c1fd8dde92acea5e8ac773e35f1d061b..3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04 100755 (executable)
@@ -1,4 +1,4 @@
-BUILD_DIR=/usr/local/build/bash/bash-current
+BUILD_DIR=/usr/local/build/chet/bash/bash-current
 THIS_SH=$BUILD_DIR/bash
 PATH=$PATH:$BUILD_DIR
 
diff --git a/trap.c b/trap.c
index 71dc64053546c075a329d92dee520e9cec8798e1..ef1d95ac43aad9b49a5431223b5d800a541334b3 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -807,6 +807,11 @@ run_return_trap ()
 {
   int old_exit_value;
 
+#if 0
+  if ((sigmodes[DEBUG_TRAP] & SIG_TRAPPED) && (sigmodes[DEBUG_TRAP] & SIG_INPROGRESS))
+    return;
+#endif
+
   if ((sigmodes[RETURN_TRAP] & SIG_TRAPPED) && ((sigmodes[RETURN_TRAP] & SIG_IGNORED) == 0) && (sigmodes[RETURN_TRAP] & SIG_INPROGRESS) == 0)
     {
       old_exit_value = last_command_exit_value;