]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.0 patch 13: reading history entries with timestamps can result in joined entries
authorChet Ramey <chet.ramey@case.edu>
Fri, 7 Feb 2020 20:17:29 +0000 (15:17 -0500)
committerChet Ramey <chet.ramey@case.edu>
Fri, 7 Feb 2020 20:17:29 +0000 (15:17 -0500)
lib/readline/histfile.c
patchlevel.h

index a8a92aa3604a52216ff29a353e282482d80c4184..6c3adc9bd8d5e441f095c19eeeef9bef0a2ec46c 100644 (file)
@@ -369,9 +369,11 @@ read_history_range (const char *filename, int from, int to)
     }
 
   has_timestamps = HIST_TIMESTAMP_START (buffer);
-  history_multiline_entries += has_timestamps && history_write_timestamps;  
+  history_multiline_entries += has_timestamps && history_write_timestamps;
 
   /* Skip lines until we are at FROM. */
+  if (has_timestamps)
+    last_ts = buffer;
   for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
     if (*line_end == '\n')
       {
@@ -380,7 +382,18 @@ read_history_range (const char *filename, int from, int to)
           line.  We should check more extensively here... */
        if (HIST_TIMESTAMP_START(p) == 0)
          current_line++;
+       else
+         last_ts = p;
        line_start = p;
+       /* If we are at the last line (current_line == from) but we have
+          timestamps (has_timestamps), then line_start points to the
+          text of the last command, and we need to skip to its end. */
+       if (current_line >= from && has_timestamps)
+         {
+           for (line_end = p; line_end < bufend && *line_end != '\n'; line_end++)
+             ;
+           line_start = (*line_end == '\n') ? line_end + 1 : line_end;
+         }
       }
 
   /* If there are lines left to gobble, then gobble them now. */
index 93dbe0db3da2cad9c9aa7a19866ddca7d3258dac..779671cd9539de449a01a1c33ea7017b611261dc 100644 (file)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 12
+#define PATCHLEVEL 13
 
 #endif /* _PATCHLEVEL_H_ */