[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-readline] History timestamps don't write to history files

From: Pavel Strashkin
Subject: [Bug-readline] History timestamps don't write to history files
Date: Wed, 11 Aug 2010 11:45:45 +0400

Hi all,

GNU History library documentation says:

== BEGIN ==
Variable: int history_write_timestamps
If non-zero, timestamps are written to the history file, so they can
be preserved between sessions. The default value is 0, meaning that
timestamps are not saved.
== END ==

OK, GNU readline tarball has history example "examples/histexamp.c".
When i set history_write_timestamps to 1, rebuild histexamp.c and run
it with some command sequence and "save" command at the end then
history file has no any timestamps, only entered lines. Wow! Why? Heh,
ok i found the reason that nowhere described in the documentation. The
reason is:
== BEGIN histexpand.c ==
/* During tokenization, if this character is seen as the first character
   of a word, then it, and all subsequent characters upto a newline are
   ignored.  For a Bourne shell, this should be '#'.  Bash special cases
   the interactive comment character to not be a comment delimiter. */
char history_comment_char = '\0';
== END ==

And then, when generating timestamp string, you're using this variable
as first char of timestamp string:
== BEGIN hist_inittime ==
  ret = savestring (ts);
  ret[0] = history_comment_char;
== END ==

And when you're writting the history file you're doing things like this:
if (timestamp[0])

== or ==

j += strlen(timestamp)

But...guys...all these expressions will fail because first char is
null-terminated char and no one timestamp will be written to history

I think you should:
  1. Change default history_comment_char value to something other ('#'
is the best char because it means comment in many stuffs)
  2. or Enter another one variable for timestamp checking
  3. or Describe it in the documentation

I and many other guys think that we should just set
history_write_timestamps to 1 and timestamps will be in file,
but...that's not enough.

Thanks for great library!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]