How to get infinite command history in bash?

I set export HISTSIZE=99999999999999 but is that the best way? I don't know if an overflow might occur. I'm looking for a tested, reliable way to remove command history limits.


it is indeed not (well) documented and I guess 99% of the bash user on this planed do set HISTSIZE to a veeery large number.

In the GNU bash history is handled through the mighty readline library. The library has the option to limit the history size ("stifle" in readline jargon) or not and bash simply sets the readline history to stifled/unstifled. If you look into e.g. GNU bash version 4.2, file variables.c, line 4443, function void sv_histsize (char*) you'll find this comment (and the whole stifling/unstifling in the function that follows):

/* What to do after the HISTSIZE or HISTFILESIZE variables change.
If there is a value for this HISTSIZE (and it is numeric), then stifle the history. Otherwise, if there is NO value for this variable,
unstifle the history. If name is HISTFILESIZE, and its value is
numeric, truncate the history file to hold no more than that many
lines. */

So this should do the trick:

export HISTSIZE=""

And also this (if you feel defiant):

export HISTSIZE="GOTCHA"

Hope this helps.