On 3/25/15 8:06 PM, Christoph Anton Mitterer wrote: > On Wed, 2015-03-25 at 16:19 -0400, Chet Ramey wrote: >> When you start bash, and source your .bashrc, the history comment character >> is not set. You haven't set it in .bashrc, I assume > Yes, I haven't. > >> Since that's not set, the lines beginning with >> `#[digit]' are not recognized as timestamps and treated as ordinary history >> entries. >> You can fix this by assigning to histchars before setting HISTFILESIZE: >> histchars='!^#' > Okay that works in principle. > > But a) this means truncation of the history file happens immediately > each the HISTFILESIZE is set and not just when the shell quits, right?
Yes. > And b) it seems kinda ugly that one needs to explicitly set a default > value that would be set later anyway. Maybe. It is what it is, and it's an effective workaround that you can use today. > Wasn't it possible to simply set the default for histchars earlier in > the startup? histchars defaulting is part of the interactive shell setup; environment variables are scanned before any other setup so they are available when the startup files are read. The interactive shell startup comes after the startup files are read so the startup files can set any appropriate variables. > Apart from that, it's not really directly obvious that histchars also > affects the history itself and not just history expansion. > E.g. it's normally not even set in my shell environment (not even the > default value). You get the default values. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/