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 -fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie uname output: Linux dawn 4.8.0-34-generic #36-Ubuntu SMP Wed Dec 21 17:24:18 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3 Patch Level: 46 Release Status: release Description: I am sorry if there is anything wrong with this report. The 'history' built-in command does not correctly track history numbers when you use the sequence 'history -r', 'history -c', 'history -r' if you have a high number of history entries. I don't know if any other settings affect this bug. The oldest history entry is not set back to 1, and using 'history -w' or 'history -a' after this could cause a problem. I noticed that my first several hundred history entries were pretty recent and duplicates of other history entries (in the 2k+ range out of 3k at the time), and this may be the cause. It appears the number is only reduced by 355 from the current maximum. Ok, I think the math I did was wrong but closed some tabs, and it seems that 'history -c' will reduce the current number by up to $HISTSIZE. 'history -r' can easily put it over this, though I also have option histappend set and not sure what it does. Repeat-By: Increase the number of lines in history to over $HISTSIZE, then use 'history -c' possibly followed by 'history -r' and then 'history -w' or 'history -a', but have not tested these last two as don't want to take risk that computer will crash before I can restore history from another tab or manually copy history file. Fix: Have 'history -c' reset the current history number to 1, but could have unexpected side effects possibly. Even if lines older than the last $HISTSIZE lines do not appear to be present in that terminal's history, they might not be removed with 'history -w' and users might somehow rely on this. Unrelated: http://pastebin.com/4ukwRxDG