]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190412 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 15 Apr 2019 13:26:31 +0000 (09:26 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 15 Apr 2019 13:26:31 +0000 (09:26 -0400)
12 files changed:
CWRU/CWRU.chlog
bashhist.c
builtins/trap.def
doc/version.texi
input.c
jobs.c
lib/glob/glob.c
lib/readline/doc/rluser.texi
lib/sh/zcatfd.c
lib/sh/zmapfd.c
redir.c
subst.c

index e70b7195ae0435c6230abe89cae8f7b360064800..2277e7073d2cadfa401b9ba8d89fbeab35bc5f46 100644 (file)
@@ -5711,3 +5711,78 @@ lib/readline/histfile.c
        - history_rename: wrapper function for rename(2) to deal with the Win32
          refusal to rename over an existing file; changed callers. Bug and fix
          from <john.david.donoghue@gmail.com>
+
+                                   4/8
+                                   ---
+builtins/trap.def
+       - display_traps,showtrap: take an additional int argument, that, if
+         non-zero, means to print a trap command for a signal whose disposition
+         is SIG_DFL
+       - trap_builtin: if the -p option is given, and posix mode is enabled,
+         pass the `show every signal' flag to display_traps so SIG_DFL signals
+         are displayed as `trap -- - <signal>'. From an austin-group
+         interpretation (1212) initiated by Robert Elz <kre@bmunnari.oz.au>.
+         Tagged for bash-5.1
+
+                                   4/9
+                                   ---
+jobs.c
+       - list_one_job: printing one job counts as notifying the user about
+         it, so add a call to cleanup_dead_jobs like in the other job display
+         functions. Fixes https://savannah.gnu.org/support/?109667 reported
+         by "Brian K. White"
+
+                                  4/10
+                                  ----
+redir.c
+       - HEREDOC_PIPESIZE: define to PIPESIZE if not defined, allow it to be
+         specified at build time; used in here_document_to_fd to determine
+         whether or not a pipe is used
+       - HEREDOC_PIPEMAX: allow build-time definition of the max heredoc size
+         that will be written to a pipe
+       - here_document_to_fd: if F_GETPIPE_SZ is defined (Linux), ensure that
+         the document is shorter than the possibly-dynamic max pipe size,
+         and fall back to the tempfile implementation if it is not
+       - HEREDOC_PARANOID: if this is defined to a non-zero value,
+         here_document_to_fd ensures that both file descriptors opened on
+         the temporary file refer to the same file
+
+lib/sh/zmapfd.c
+       - zmapfd: increased the default allocation sizes
+
+lib/sh/zcatfd.c
+       - zcatfd: increased the default allocation sizes
+
+input.c
+       - localbuf: increased the default buffer size for reads
+
+                                  4/11
+                                  ----
+subst.c
+       - cond_expand_word: like expand_word_unsplit, we need to peform
+         quoted null character removal on both the LHS and RHS of the
+         operator, since we are not performing word splitting. Fixes bug
+         reported by Matt Whitlock in https://savannah.gnu.org/support/?109671
+
+                                  4/12
+                                  ----
+jobs.c
+       - wait_for_background_pids: don't bother with the loop that waits for
+         and reaps all children of the shell in the case that it's inherited
+         some children it doesn't care about. Report from Daniel Kahn Gillmor
+         <dkg@fifthhorseman.net>
+
+                                  4/14
+                                  ----
+subst.c
+       - command_substitute: add an unwind-protect to make sure the read end
+         of the pipe gets closed in the parent on a SIGINT that interrupts
+         the zread. Fixes fast SIGINT fd leak reported by Tycho Kirchner
+         <tychokirchner@mail.de>
+
+bashhist.c
+       - history_number: if enable_history_list is set (`set -o history' has
+         been executed), return the current history number even if we're
+         not currently saving commands in the history list
+         (remember_on_history == 0). Prompted by report from Paul Wise
+         <pabs3@bonedaddy.net>
index 710372b2e563e40141cda6af3ca690813fb86886..ed16d7a71e4d2e97690cd3e387f79905f2bc41be 100644 (file)
@@ -1,6 +1,6 @@
 /* bashhist.c -- bash interface to the GNU history library. */
 
-/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -943,7 +943,7 @@ int
 history_number ()
 {
   using_history ();
-  return (remember_on_history ? history_base + where_history () : 1);
+  return ((remember_on_history || enable_history_list) ? history_base + where_history () : 1);
 }
 
 static int
index 09846981f75b23684a41912228e0ab4734cc98f6..2848b77633f47bb0b680f60617f50411af984cc2 100644 (file)
@@ -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-2015 Free Software Foundation, Inc.
+Copyright (C) 1987-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -75,8 +75,8 @@ $END
 #include "common.h"
 #include "bashgetopt.h"
 
-static void showtrap __P((int));
-static int display_traps __P((WORD_LIST *));
+static void showtrap __P((int, int));
+static int display_traps __P((WORD_LIST *, int));
 
 /* The trap command:
 
@@ -133,7 +133,11 @@ trap_builtin (list)
     {
       initialize_terminating_signals ();
       get_all_original_signals ();
-      return (sh_chkwrite (display_traps (list)));
+#if 0  /* TAG:bash-5.1 */
+      return (sh_chkwrite (display_traps (list, display && posixly_correct)));
+#else
+      return (sh_chkwrite (display_traps (list, 0)));
+#endif
     }
   else
     {
@@ -246,14 +250,19 @@ trap_builtin (list)
 }
 
 static void
-showtrap (i)
-     int i;
+showtrap (i, show_default)
+     int i, show_default;
 {
   char *t, *p, *sn;
 
   p = trap_list[i];
   if (p == (char *)DEFAULT_SIG && signal_is_hard_ignored (i) == 0)
-    return;
+    {
+      if (show_default)
+       t = "-";
+      else
+       return;
+    }
   else if (signal_is_hard_ignored (i))
     t = (char *)NULL;
   else
@@ -274,19 +283,21 @@ showtrap (i)
   else
     printf ("trap -- %s %s\n", t ? t : "''", sn);
 
-  FREE (t);
+  if (show_default == 0)
+    FREE (t);
 }
 
 static int
-display_traps (list)
+display_traps (list, show_all)
      WORD_LIST *list;
+     int show_all;
 {
   int result, i;
 
   if (list == 0)
     {
       for (i = 0; i < BASH_NSIG; i++)
-       showtrap (i);
+       showtrap (i, show_all);
       return (EXECUTION_SUCCESS);
     }
 
@@ -299,7 +310,7 @@ display_traps (list)
          result = EXECUTION_FAILURE;
        }
       else
-       showtrap (i);
+       showtrap (i, show_all);
     }
 
   return (result);
index b98da09406c9026a54eaae401703614c4258ef76..aad2600d9d370fd99dd958b58ee2c030d5cc8211 100644 (file)
@@ -2,10 +2,10 @@
 Copyright (C) 1988-2019 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Sun Mar 24 14:05:55 EDT 2019
+@set LASTCHANGE Fri Apr 12 16:27:08 EDT 2019
 
 @set EDITION 5.0
 @set VERSION 5.0
 
-@set UPDATED 24 March 2019
-@set UPDATED-MONTH March 2019
+@set UPDATED 12 April 2019
+@set UPDATED-MONTH April 2019
diff --git a/input.c b/input.c
index 8b3e4259b9afe4d801bfb78366fb0ca947e631e5..c5192a24ebf5852d1e0a2955f5e8446f1df1cbb6 100644 (file)
--- a/input.c
+++ b/input.c
@@ -62,7 +62,7 @@ extern void termsig_handler __P((int));
 /* Functions to handle reading input on systems that don't restart read(2)
    if a signal is received. */
 
-static char localbuf[128];
+static char localbuf[1024];
 static int local_index = 0, local_bufused = 0;
 
 /* Posix and USG systems do not guarantee to restart read () if it is
diff --git a/jobs.c b/jobs.c
index fae63f07b3357e751bf53e074223eef585c905f0..380704cc1962236f7c9eb3b3f84cbdcab469d7fc 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -1885,6 +1885,7 @@ list_one_job (job, format, ignore, job_index)
      int format, ignore, job_index;
 {
   pretty_print_job (job_index, format, stdout);
+  cleanup_dead_jobs ();
 }
 
 void
@@ -2488,10 +2489,8 @@ wait_for_background_pids ()
     r = wait_for (last_procsub_child->pid);
   wait_procsubs ();
   reap_procsubs ();
-#if 1
+#if 0
   /* We don't want to wait indefinitely if we have stopped children. */
-  /* XXX - should add a loop that goes through the list of process
-     substitutions and waits for each proc in turn before this code. */
   if (any_stopped == 0)
     {
       /* Check whether or not we have any unreaped children. */
index 50c263da1a76c01abfcbef6fc64babe2a5aab2aa..c69d948950cb176dc720e3c2c6e42447259b58bd 100644 (file)
@@ -823,6 +823,7 @@ glob_vector (pat, dir, flags)
                    }
                }
 
+#if 0
              /* When FLAGS includes GX_ALLDIRS, we want to skip a symlink
                 to a directory, since we will pick the directory up later. */
              if (isdir == -2 && glob_testdir (subdir, 0) == 0)
@@ -830,6 +831,7 @@ glob_vector (pat, dir, flags)
                  free (subdir);
                  continue;
                }
+#endif
 
              /* XXX - should we even add this if it's not a directory? */
              nextlink = (struct globval *) malloc (sizeof (struct globval));
index bbe41e1e3ecd986a831ccc78edaa739f3dac9923..e8cb9a45947f66bbe66d161e0e0b926b6510a209 100644 (file)
@@ -2380,7 +2380,7 @@ Many more examples -- an extensive collection of completions for most of
 the common GNU, Unix, and Linux commands -- are available as part of the
 bash_completion project.  This is installed by default on many GNU/Linux
 distributions.  Originally written by Ian Macdonald, the project now lives
-at @url{http://bash-completion.alioth.debian.org/}.  There are ports for
+at @url{https://salsa.debian.org/debian/bash-completion}.  There are ports for
 other systems such as Solaris and Mac OS X.
 
 An older version of the bash_completion package is distributed with bash
index bdbcd910529ca874f5ae5364aca2a88dbb943adb..b0efc940e0aaeb7cce6f5361f996df6f8f3101b9 100644 (file)
@@ -46,7 +46,7 @@ zcatfd (fd, ofd, fn)
 {
   ssize_t nr;
   int rval;
-  char lbuf[128];
+  char lbuf[1024];
 
   rval = 0;
   while (1)
index e720892111c6f76915faaea1f4bed62871ecb94d..c5544e67f124165f53d626ac8ad5b6e6e0ed6e85 100644 (file)
@@ -48,12 +48,12 @@ zmapfd (fd, ostr, fn)
 {
   ssize_t nr;
   int rval;
-  char lbuf[128];
+  char lbuf[512];
   char *result;
   int rsize, rind;
 
   rval = 0;
-  result = (char *)xmalloc (rsize = 64);
+  result = (char *)xmalloc (rsize = 512);
   rind = 0;
 
   while (1)
@@ -72,7 +72,7 @@ zmapfd (fd, ostr, fn)
          return -1;
        }
 
-      RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 128);
+      RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 512);
       memcpy (result+rind, lbuf, nr);
       rind += nr;
     }
diff --git a/redir.c b/redir.c
index 40ea6f2d1bc7d19e28ab19cbf1d409bb9159f319..6f4e600bfb99f77f66c0d883993f30a690dadc4d 100644 (file)
--- a/redir.c
+++ b/redir.c
@@ -69,6 +69,16 @@ extern int errno;
 #  endif
 #endif
 
+#ifndef HEREDOC_PIPESIZE
+#  define HEREDOC_PIPESIZE PIPESIZE
+#endif
+
+#if defined (HEREDOC_PIPEMAX)
+#  if HEREDOC_PIPESIZE > HEREDOC_PIPEMAX
+#    define HEREDOC_PIPESIZE HEREDOC_PIPEMAX
+#  endif
+#endif
+
 #define SHELL_FD_BASE  10
 
 int expanding_redir;
@@ -418,6 +428,9 @@ here_document_to_fd (redirectee, ri)
   int r, fd, fd2, herepipe[2];
   char *document;
   size_t document_len;
+#if HEREDOC_PARANOID
+  struct stat st1, st2;
+#endif
 
   /* Expand the here-document/here-string first and then decide what to do. */
   document = heredoc_expand (redirectee, ri, &document_len);
@@ -433,11 +446,11 @@ here_document_to_fd (redirectee, ri)
       return fd;
     }
 
-#if defined (PIPESIZE)
+#if defined (HEREDOC_PIPESIZE)
   /* Try to use a pipe internal to this process if the document is shorter
      than the system's pipe capacity (computed at build time). We want to
      write the entire document without write blocking. */
-  if (document_len <= PIPESIZE)
+  if (document_len <= HEREDOC_PIPESIZE)
     {
       if (pipe (herepipe) < 0)
        {
@@ -447,6 +460,12 @@ here_document_to_fd (redirectee, ri)
          errno = r;
          return (-1);
        }
+
+#if defined (F_GETPIPE_SZ)
+      if (fcntl (herepipe[1], F_GETPIPE_SZ, 0) < document_len)
+       goto use_tempfile;
+#endif
+
       r = heredoc_write (herepipe[1], document, document_len);
       if (document != redirectee->word)
        free (document);
@@ -461,6 +480,8 @@ here_document_to_fd (redirectee, ri)
     }
 #endif
 
+use_tempfile:
+
   fd = sh_mktmpfd ("sh-thd", MT_USERANDOM|MT_USETMPDIR, &filename);
 
   /* If we failed for some reason other than the file existing, abort */
@@ -506,6 +527,22 @@ here_document_to_fd (redirectee, ri)
       return -1;
     }
 
+#if HEREDOC_PARANOID
+  /* We can use same_file here to check whether or not fd and fd2 refer to
+     the same file, but we don't do that unless HEREDOC_PARANOID is defined. */
+  if (fstat (fd, &st1) < 0 || S_ISREG (st1.st_mode) == 0 ||
+      fstat (fd2, &st2) < 0 || S_ISREG (st2.st_mode) == 0 ||
+      same_file (filename, filename, &st1, &st2) == 0)
+    {
+      unlink (filename);
+      free (filename);
+      close (fd);
+      close (fd2);
+      errno = EEXIST;
+      return -1;
+    }
+#endif
+
   close (fd);
   if (unlink (filename) < 0)
     {
diff --git a/subst.c b/subst.c
index 47d9dbc8b960acdb3b9a005f4a3011973354bb74..3a70d725ca36f681f844d6cb742fb350804528e9 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3641,7 +3641,9 @@ remove_backslashes (string)
    this case, we quote the string specially for the globbing code.  If
    SPECIAL is 2, this is an rhs argument for the =~ operator, and should
    be quoted appropriately for regcomp/regexec.  The caller is responsible
-   for removing the backslashes if the unquoted word is needed later. */   
+   for removing the backslashes if the unquoted word is needed later. In
+   any case, since we don't perform word splitting, we need to do quoted
+   null character removal. */
 char *
 cond_expand_word (w, special)
      WORD_DESC *w;
@@ -3662,6 +3664,8 @@ cond_expand_word (w, special)
     {
       if (special == 0)                        /* LHS */
        {
+         if (l->word)
+           word_list_remove_quoted_nulls (l);
          dequote_list (l);
          r = string_list (l);
        }
@@ -6414,16 +6418,23 @@ command_substitute (string, quoted, flags)
     }
   else
     {
+      int dummyfd;
+
 #if defined (JOB_CONTROL) && defined (PGRP_PIPE)
       close_pgrp_pipe ();
 #endif /* JOB_CONTROL && PGRP_PIPE */
 
       close (fildes[1]);
 
+      begin_unwind_frame ("read-comsub");
+      dummyfd = fildes[0];
+      add_unwind_protect (close, dummyfd);
+
       tflag = 0;
       istring = read_comsub (fildes[0], quoted, flags, &tflag);
 
       close (fildes[0]);
+      discard_unwind_frame ("read-comsub");
 
       current_command_subst_pid = pid;
       last_command_exit_value = wait_for (pid);