bug-bash
[Top][All Lists]
Advanced

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

bash history with mixed timestamps slow and broken


From: Hubert Schmid
Subject: bash history with mixed timestamps slow and broken
Date: Sat, 24 Sep 2016 19:17:42 +0100

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-31ueiH/bash-4.4=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux vivo 4.7.0-1-amd64 #1 SMP Debian 4.7.4-2 (2016-09-19) 
x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
        If the history file (`.bash_history`) starts with a timestamp
        (`HIST_TIMESTAMP_START`), and contains lines that have been written
        without timestamps, then reading the history file is (a) very slow
        because (b) consecutive lines without timestamps are merged into a
        single history entry with quadratic complexity.

        Apparently, this problem didn't exist in the previous version (4.3).

Repeat-By:
        (1) Start with an empty `.bash_history` and a `.bashrc` containing the
        following lines:

        shopt -s histappend
        HISTSIZE=-1
        HISTFILESIZE=-1
        HISTTIMEFORMAT="%F %T "

        (2) Invoke `bash`, execute `echo foobar`, and exit the shell, so that
        the history file contains one entry and starts with a timestamp.

        (3) Remove `HISTTIMEFORMAT` from `.bashrc`.

        (4) Invoke `bash`, execute 1 Mio different commands, and exit the
        shell.

        (5) Invoke `bash`, and wait an hour for the prompt to appear.

Fix:
        Do not set `history_multiline_entries` to a non-zero value in
        `lib/readline/histfile.c`.

        Workaround without changing the code: Add a dummy history entry add
        the beginning of the history file without a timestamp. That has a
        similar effect as the code change, i.e. multi-line entries are not
        supported, and consecutive lines without timestamps will not be merged
        into a line history entry.



reply via email to

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