Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15859 > unrolled thread

Readline history bug

Started byA <auroralanes@protonmail.ch>
First post2020-01-31 20:32 +0000
Last post2020-01-31 20:32 +0000
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Readline history bug A <auroralanes@protonmail.ch> - 2020-01-31 20:32 +0000

#15859 — Readline history bug

FromA <auroralanes@protonmail.ch>
Date2020-01-31 20:32 +0000
SubjectReadline history bug
Message-ID<mailman.88.1580515675.2412.bug-bash@gnu.org>

[Multipart message — attachments visible in raw view] — view raw

The readline package doesn't return the errno for some errors in write_history, append_history, and history_truncate_file.
This caused an error in the CPython interpreter(at exit time) when the .python_history file was not writable.

In particular these calls return -1 when the internal`histfile_restore`call fails because`rename`fails. It's fine for`histfile_restore`to return the result from`rename`, but this should be checked for failure (e.g. -1) and handled appropriately by the caller in`history_do_write`and`history_truncate_file`. For example, in`history_do_write`they do the following:

if (rv == 0 && histname && tempname)
    rv = histfile_restore (tempname, histname);

if (rv != 0)
    {
      if (tempname)
	unlink (tempname);
      history_lines_written_to_file = 0;
    }

This needs a simple fix to update the value of`rv`when`histfile_restore`fails:

if (rv == 0 && histname && tempname)
    rv = histfile_restore (tempname, histname);

if (rv != 0) {
    rv = errno;
    if (tempname)
        unlink(tempname);
    history_lines_written_to_file = 0;
}

Code snippet taken from https://github.com/python/cpython/pull/18299#issuecomment-580883515

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web