3

I'm using this in my .bashrc since 2 years now, and never noticed any problem...until recently.

I noticed that the .bash_eternal_history, which was more than 40k lines, suddenly get truncated on new login, down to a couple hundreds lines.

I tried checking HISTSIZE and HISTFILESIZE but it was still returning nothing (which i assume mean it doesn't have any limits)

I'm aware of other post that mention that unsetting those variable is preferred, but like another one this doesn't seem to always be the case.

I did found an alternative (didn't tried it yet) such as this one.

I'm using Ubuntu's default .bashrc, with HISTSIZE and HISTFILESIZE commented, since already part of the defaults. (so that it doesn't interfere with the snippet mentioned above)

Other related posts that was consulted:

I didn't yet tried the alternative i mentioned above, and so I'm curious if there could be other reasons for this to happen, beside what was already mentioned on the mentioned posts.

Nordine Lotfi
  • 2,200
  • 12
  • 45

1 Answers1

2

From man bash:

   HISTFILESIZE
          The maximum number of lines  contained  in  the  history  file.
          When  this  variable  is  assigned a value, the history file is
          truncated, if necessary, to contain no more than that number of
          lines by removing the oldest entries.  The history file is also
          truncated to this size after writing it when a shell exits.  If
          the  value  is  0,  the history file is truncated to zero size.
          Non-numeric values and numeric values less  than  zero  inhibit
          truncation.   The  shell sets the default value to the value of
          HISTSIZE after reading any startup files.
   HISTSIZE
          The  number of commands to remember in the command history (see
          HISTORY below).  If the value is 0, commands are not  saved  in
          the  history list.  Numeric values less than zero result in ev‐
          ery command being saved  on  the  history  list  (there  is  no
          limit).   The shell sets the default value to 500 after reading
          any startup files.

So if neither are set, the code will still default to 500 for both.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
l0b0
  • 50,672
  • 41
  • 197
  • 360
  • but as i mentioned, i did check the value of those two value, and they weren't set at any value (didn't return anything when i checked with echo) – Nordine Lotfi Sep 24 '20 at 16:30
  • I think "sets the default value" is misleading, and just means the *internal state* of the shell is that the history sizes are 500. The variables are just a *copy* of that state so that it's (normally) easily interrogated by the end user. – l0b0 Sep 24 '20 at 20:33