summaryrefslogtreecommitdiff
path: root/app-shells/bash/files/bash-5.0-history-append.patch
blob: 20f78bfe9f036059075e32f9385261acf3460d7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
*** ../bash-5.0-patched/bashhist.c	2018-07-05 22:41:14.000000000 -0400
--- bashhist.c	2019-02-23 17:12:02.000000000 -0500
***************
*** 437,445 ****
       char *filename;
  {
!   int fd, result;
    struct stat buf;
  
    result = EXECUTION_SUCCESS;
!   if (history_lines_this_session > 0 && (history_lines_this_session <= where_history ()))
      {
        /* If the filename was supplied, then create it if necessary. */
--- 437,445 ----
       char *filename;
  {
!   int fd, result, histlen;
    struct stat buf;
  
    result = EXECUTION_SUCCESS;
!   if (history_lines_this_session > 0)
      {
        /* If the filename was supplied, then create it if necessary. */
***************
*** 454,457 ****
--- 454,461 ----
  	  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