]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190223 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 25 Feb 2019 13:48:43 +0000 (08:48 -0500)
committerChet Ramey <chet.ramey@case.edu>
Mon, 25 Feb 2019 13:48:43 +0000 (08:48 -0500)
CWRU/CWRU.chlog
MANIFEST
bashhist.c
bashline.c
lib/readline/complete.c
tests/quote.right
tests/quote.tests
tests/quote3.sub [new file with mode: 0644]

index 4442a20d5d76d3f83069f9e96f1ad46a397375b7..86c626055b8ca661d466b30ec25db2efd814ed0b 100644 (file)
@@ -5358,3 +5358,26 @@ subst.c
          will eventually be split and we need to preserve the null to
          produce an empty word. From a discussion on bug-bash started by
          sunnycemetery@gmail.com
+
+                                  2/22
+                                  ----
+bashline.c
+       - completion_glob_pattern: make sure to skip over a character quoted
+         by a backslash. Fixes bug reported by John Van Sickle
+         <john.vansickle@gmail.com>
+
+                                  2/23
+                                  ----
+lib/readline/complete.c
+       - last_completion_failed: keep track of whether the last completion
+         attempt generated any matches
+       - rl_complete: if the last readline command was completion, but the
+         completion attempt didn't generate any matches, don't regenerate
+         and display the match list. Treat it as a new completion attempt.
+         Suggested by Richard Stallman <rms@gnu.org>
+
+bashhist.c
+       - maybe_append_history: try to handle the case where the number of
+         history entries in the current shell session is greater than the
+         number of entries in the history list. Based on a report from
+         <airat_vi@mail.ru>
index 5c9a37bbbf70e28370a9021eb806c2dd8bd8e302..fea4c1a8c2030dfab1faefb0f525eab60c5d381a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1249,6 +1249,7 @@ tests/quote.tests f
 tests/quote.right      f
 tests/quote1.sub       f
 tests/quote2.sub       f
+tests/quote3.sub       f
 tests/read.tests       f
 tests/read.right       f
 tests/read1.sub                f
index f7f168ff2d9b16acef6da7bb308d9e06350257e8..710372b2e563e40141cda6af3ca690813fb86886 100644 (file)
@@ -436,11 +436,11 @@ int
 maybe_append_history (filename)
      char *filename;
 {
-  int fd, result;
+  int fd, result, histlen;
   struct stat buf;
 
   result = EXECUTION_SUCCESS;
-  if (history_lines_this_session > 0 && (history_lines_this_session <= where_history ()))
+  if (history_lines_this_session > 0)
     {
       /* If the filename was supplied, then create it if necessary. */
       if (stat (filename, &buf) == -1 && errno == ENOENT)
@@ -453,6 +453,10 @@ maybe_append_history (filename)
            }
          close (fd);
        }
+      /* cap the number of lines we write at the length of the history list */
+      histlen = where_history ();
+      if (histlen > 0 && history_lines_this_session > histlen)
+       history_lines_this_session = histlen;   /* reset below anyway */
       result = append_history (history_lines_this_session, filename);
       /* Pretend we already read these lines from the file because we just
         added them */
index 34e2e34ad15df6d0145f1e4a63c53ab42842a9fd..0e25017143ced59aac34984c977efdb5f623202f 100644 (file)
@@ -3765,7 +3765,7 @@ completion_glob_pattern (string)
          continue;
 
        case '\\':
-         if (*string == 0)
+         if (*string++ == 0)
            return (0);           
        }
 
index adce0d69ac1d9bbf57a335c1fb0c6df36d9320c2..7da8ee98f4e60ae9adc023f670f2b14de1d383fc 100644 (file)
@@ -406,6 +406,7 @@ int rl_sort_completion_matches = 1;
 
 /* Local variable states what happened during the last completion attempt. */
 static int completion_changed_buffer;
+static int last_completion_failed = 0;
 
 /* The result of the query to the user about displaying completion matches */
 static int completion_y_or_n;
@@ -428,7 +429,7 @@ rl_complete (int ignore, int invoking_key)
 
   if (rl_inhibit_completion)
     return (_rl_insert_char (ignore, invoking_key));
-  else if (rl_last_func == rl_complete && !completion_changed_buffer)
+  else if (rl_last_func == rl_complete && completion_changed_buffer == 0 && last_completion_failed == 0)
     return (rl_complete_internal ('?'));
   else if (_rl_complete_show_all)
     return (rl_complete_internal ('!'));
@@ -477,7 +478,7 @@ rl_completion_mode (rl_command_func_t *cfunc)
 /*                                 */
 /************************************/
 
-/* Reset readline state on a signal or other event. */
+/* Reset public readline state on a signal or other event. */
 void
 _rl_reset_completion_state (void)
 {
@@ -2023,6 +2024,7 @@ rl_complete_internal (int what_to_do)
       rl_ding ();
       FREE (saved_line_buffer);
       completion_changed_buffer = 0;
+      last_completion_failed = 1;
       RL_UNSETSTATE(RL_STATE_COMPLETING);
       _rl_reset_completion_state ();
       return (0);
@@ -2038,11 +2040,15 @@ rl_complete_internal (int what_to_do)
       rl_ding ();
       FREE (saved_line_buffer);
       completion_changed_buffer = 0;
+      last_completion_failed = 1;
       RL_UNSETSTATE(RL_STATE_COMPLETING);
       _rl_reset_completion_state ();
       return (0);
     }
 
+  if (matches && matches[0] && *matches[0])
+    last_completion_failed = 0;
+
   switch (what_to_do)
     {
     case TAB:
index 174384aa1b47115075b7bf01ac0941ddf10f7ab5..cb291eb858588d14842514f4c3a1a6d5393ea45f 100644 (file)
@@ -128,3 +128,17 @@ argv[2] = <>
 argv[1] = <>
 argv[2] = <>
 argv[1] = <>
+argv[1] = <4>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab>
+argv[2] = <>
+argv[1] = <ab ''>
+argv[1] = <ab >
+argv[1] = <ab ''>
+argv[1] = <ab >
index d7f13cd0c3005462724667e12a02c6a1d356f32f..402da2d59585c95fb5584998298e48373ceaec13 100644 (file)
@@ -122,3 +122,4 @@ echo ${foo:-string \\\}}
 
 ${THIS_SH} ./quote1.sub
 ${THIS_SH} ./quote2.sub
+${THIS_SH} ./quote3.sub
diff --git a/tests/quote3.sub b/tests/quote3.sub
new file mode 100644 (file)
index 0000000..4822868
--- /dev/null
@@ -0,0 +1,18 @@
+# new tests
+x=4
+sp=' '
+
+# word
+recho ${x}${sp}''
+
+# unquoted
+recho ${x+ab "$y"}
+recho ${x+ab ''}
+recho ${x+ab "$( : )"}
+recho ${x+ab "${yy}"}
+
+# quoted
+recho "${x+ab ''}"
+recho "${x+ab ""}"
+recho "${x+ab '${yy}'}"
+recho "${x+ab "${yy}"}"