2

i used to enable lithist option, which make bash history store in multiline, but one day, the lithist option not work.

enabling lithist mean you can store multiline in one history entry. if you type some command enclosed by bracket:

~:$ (
> echo hey
> echo bye
> )
hey
bye

then press ctrl-p , you will see this:

~:$ (
echo hey
echo bye
)

in my bad day that lithist broken, one will see multiline splitted into multiple entry

# press ctrl-p
~:$ )
# press ctrl-p again
~:$ echo bye

this problem occur a few times before. it is usually happend because the size of ~/.bash_history exceed the variable HISTFILESIZE , and bash truncate the ~/.bash_history, which make format of history file broken. i used to remove some beginning line of history file, then restart the shell, and history would recovery.

however, this time it does not recover even after i remove the whole history file.

my config:

HISTSIZE=1000
HISTFILESIZE=8000
shopt -s cmdhist lithist

with lithist working, the output of command history should look like to following:

 4519* 2019-08-24 15:46:05 (
echo hey
echo bye
)
 4520  2019-08-24 16:00:21 history
 4521  2019-08-24 16:00:23 history  | less

the output of history broken when lithist broken, too:

    1  2019-08-24 14:25:04 \rm .bash_history
    2  2019-08-24 14:25:13 (
    3  2019-08-24 14:42:26 echo a
    4  2019-08-24 14:42:26 echo c
    5  2019-08-24 14:42:26 )

however, my history file looked ok:

#1566627904
\rm .bash_history
#1566627913
(
echo a
echo c
)
#1566627926
echo bye

this behavior appear on CentOS 6.10 , and can not be fix, but can be fix on another machine with debian stretch.

  • 1
    I can find no actual question in your message. The type of Linux you are running is (mostly) irrelevant, but it would be good to know the version of bash that you are running (when it works and when it does not work). Changes made to particular versions of bash (including bug fixes) may be found at tiswww.case.edu/php/chet/bash/CHANGES If you think you have found a genuine bug in the shell, there's a bashbug command for reporting it. – Kusalananda Aug 24 '19 at 8:15
  • the question is why lithist not work. bash in centos6 is 4.1.2(2) , and bash in debian stretch is 4.1.2(1) . i am not sure it is a bug. – gholk Aug 24 '19 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.