]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190321 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 22 Mar 2019 13:08:20 +0000 (09:08 -0400)
committerChet Ramey <chet.ramey@case.edu>
Fri, 22 Mar 2019 13:08:20 +0000 (09:08 -0400)
CWRU/CWRU.chlog
execute_cmd.c
lib/readline/misc.c
lib/sh/strtrans.c
patchlevel.h
subst.c
variables.c

index 4526e344ea7f8998631508cd33916113bfc72114..ab18ef22e26cccb5f194df76c43583c700766a91 100644 (file)
@@ -5589,3 +5589,40 @@ subst.c
        - chk_atstar: if we see "$*" don't note that we saw $@ unless
          expand_no_split_dollar_star is unset. This is what param_expand
          does
+
+                                  3/18
+                                  ----
+lib/readline/misc.c
+       - rl_get_previous_history: if we are trying to go back from the
+         beginning of the history, or if we are trying to go back before the
+         beginning of the history, call _rl_free_saved_history_line to just
+         get rid of the history line we saved instead of using
+         rl_maybe_unsave_line, which modifies the current line buffer.
+         Fixes bug reported by lessbug <lessbug@qq.com>
+
+                                  3/20
+                                  ----
+execute_cmd.c
+       - execute_command_internal: save and restore line_number around
+         user_subshell setting it to the line number saved in the command.
+         Fixes bug reported in https://bugzilla.novell.com/show_bug.cgi?id=1128936
+
+                                  3/21
+                                  ----
+lib/sh/strtrans.c
+       - ansicstr: handle multibyte characters that are not preceded by a
+         backslash so we skip over potential escapes in characters whose
+         multibyte representation contains a backslash. Fixes issue reported by
+         Stephane Chazelas <stephane.chazelas@gmail.com>
+
+subst.c
+       - reap_some_procsubs: reap_procsubs, but parameterized to take the
+         max index to check -- general function for future use
+       - reap_procsubs: now just calls reap_some_procsubs with the right arg
+
+execute_cmd.c
+       - execute_command_internal: if we are using /dev/fd for process
+         substitution, reap the procsubs at the end of this function (FIFOs
+         do it at the beginning -- look at this more closely). Only do it
+         for loops to avoid fd exhaustion. Fixes bug reported by
+         sunnycemetery@gmail.com
index e4a05e2eda62dec1a3aa154e9fed849d3a01c1d7..7f5f41f6c2c954be3aa8d126accf8f4ed0d01dc1 100644 (file)
@@ -624,6 +624,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
 
       /* Fork a subshell, turn off the subshell bit, turn off job
         control and call execute_command () on the command again. */
+      save_line_number = line_number;
       if (command->type == cm_subshell)
        line_number_for_err_trap = line_number = command->value.Subshell->line; /* XXX - save value? */
        /* Otherwise we defer setting line_number */
@@ -677,6 +678,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
 
          stop_pipeline (asynchronous, (COMMAND *)NULL);
 
+         line_number = save_line_number;
+
          if (asynchronous == 0)
            {
              was_error_trap = signal_is_trapped (ERROR_TRAP) && signal_is_ignored (ERROR_TRAP) == 0;
@@ -1103,6 +1106,21 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
       free ((void *)ofifo_list);
       discard_unwind_frame ("internal_fifos");
     }
+# if defined (HAVE_DEV_FD)
+  /* Reap process substitutions at the end of loops */
+  switch (command->type)
+    {
+    case cm_while:
+    case cm_until:
+    case cm_for:
+#    if defined (ARITH_FOR_COMMAND)
+    case cm_arith_for:
+#    endif
+      reap_procsubs ();
+    default:
+      break;
+    }
+#  endif /* HAVE_DEV_FD */
 #endif
 
   /* Invert the return value if we have to */
index 6c993f5dc9ea3376e0589f2066336847f0f07ef2..5e7979312cae622be6afb14abbdb341d31d2e188 100644 (file)
@@ -624,7 +624,7 @@ rl_get_previous_history (int count, int key)
 
   if (temp == 0)
     {
-      rl_maybe_unsave_line ();
+      _rl_free_saved_history_line ();
       rl_ding ();
     }
   else
index 48f255f5d39baa0197a2034b415c3a1758f62f04..b2b1acca3348d18ba08bd43975f151f178c644cc 100644 (file)
@@ -55,12 +55,18 @@ ansicstr (string, len, flags, sawc, rlen)
   int c, temp;
   char *ret, *r, *s;
   unsigned long v;
+  size_t clen;
+  int b, mb_cur_max;
+#if defined (HANDLE_MULTIBYTE)
+  wchar_t wc;
+#endif
 
   if (string == 0 || *string == '\0')
     return ((char *)NULL);
 
+  mb_cur_max = MB_CUR_MAX;
 #if defined (HANDLE_MULTIBYTE)
-  temp = 4*len + 1;
+  temp = 4*len + 4;
   if (temp < 12)
     temp = 12;                         /* ensure enough for eventual u32cesc */
   ret = (char *)xmalloc (temp);
@@ -71,7 +77,21 @@ ansicstr (string, len, flags, sawc, rlen)
     {
       c = *s++;
       if (c != '\\' || *s == '\0')
-       *r++ = c;
+       {
+         clen = 1;
+#if defined (HANDLE_MULTIBYTE)
+         if ((locale_utf8locale && (c & 0x80)) ||
+             (locale_utf8locale == 0 && mb_cur_max > 0 && is_basic (c) == 0))
+           {
+             clen = mbrtowc (&wc, s - 1, mb_cur_max, 0);
+             if (MB_INVALIDCH (clen))
+               clen = 1;
+           }
+#endif
+         *r++ = c;
+         for (--clen; clen > 0; clen--)
+           *r++ = *s++;
+       }
       else
        {
          switch (c = *s++)
index a988d852644985230969d343fdc0c88a3626f7a4..4c9998e61ce00fbdff38df8b4f1687a3f2888815 100644 (file)
@@ -25,6 +25,7 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 2
+#define PATCHLEVEL 3
 
 #endif /* _PATCHLEVEL_H_ */
+
diff --git a/subst.c b/subst.c
index 62a3b37555ee626776c25dba5a72454262e49476..47d9dbc8b960acdb3b9a005f4a3011973354bb74 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -5321,6 +5321,8 @@ parameter_brace_remove_pattern (varname, value, ind, patstr, rtype, quoted, flag
 
 #if defined (PROCESS_SUBSTITUTION)
 
+static void reap_some_procsubs __P((int));
+
 /*****************************************************************/
 /*                                                              */
 /*                 Hacking Process Substitution                 */
@@ -5482,16 +5484,23 @@ set_procsub_status (ind, pid, status)
 
 /* If we've marked the process for this procsub as dead, close the
    associated file descriptor and delete the FIFO. */
-void
-reap_procsubs ()
+static void
+reap_some_procsubs (max)
+     int max;
 {
   int i;
 
-  for (i = 0; i < nfifo; i++)
+  for (i = 0; i < max; i++)
     if (fifo_list[i].proc == (pid_t)-1)        /* reaped */
       unlink_fifo (i);
 }
 
+void
+reap_procsubs ()
+{
+  reap_some_procsubs (nfifo);
+}
+
 void
 wait_procsubs ()
 {
@@ -5708,16 +5717,23 @@ set_procsub_status (ind, pid, status)
 
 /* If we've marked the process for this procsub as dead, close the
    associated file descriptor. */
-void
-reap_procsubs ()
+static void
+reap_some_procsubs (max)
+     int max;
 {
   int i;
 
-  for (i = 0; nfds > 0 && i < totfds; i++)
+  for (i = 0; nfds > 0 && i < max; i++)
     if (dev_fd_list[i] == (pid_t)-1)
       unlink_fifo (i);
 }
 
+void
+reap_procsubs ()
+{
+  reap_some_procsubs (totfds);
+}
+
 void
 wait_procsubs ()
 {
index 90c16d875cd2bab0aaa7bf8c455ac6e21f8d47b3..00118bdafd2d4851d4477dbbc39baa32a05aa8c6 100644 (file)
@@ -4465,7 +4465,8 @@ push_posix_temp_var (data)
 #if 0 /* TAG:bash-5.1 */
   /* Just like do_assignment_internal(). This makes assignments preceding
      special builtins act like standalone assignment statements when in
-     posix mode. */
+     posix mode, satisfying the posix requirement that this affect the
+     "current execution environment." */
   v = bind_variable (var->name, value_cell (var), ASS_FORCE|ASS_NOLONGJMP);
 
   /* If this modifies an existing local variable, v->context will be non-zero.
@@ -5148,6 +5149,7 @@ push_var_context (name, flags, tempvars)
       vc->table = tempvars;
       /* Have to do this because the temp environment was created before
         variable_context was incremented. */
+      /* XXX - only need to do it if flags&VC_FUNCENV */
       flatten (tempvars, set_context, (VARLIST *)NULL, 0);
       vc->flags |= VC_HASTMPVAR;
     }