On 6/19/24 9:45 AM, Andreas Schwab wrote:
$ printf 'echo 1234\necho 2345\necho 3456\n' > history
$ HOME=$PWD HISTFILE=history TERM=xterm bash --norc -i 
<<<$'\20\eb1\e[5~\nhistory\n\20\20\eb2\e[5~\nhistory'
bash-5.3$ echo 1234
1234
bash-5.3$ history
     1  echo 1234
     2  echo 2345
     3  echo 13456
     4  echo 1234
     5  history
bash-5.3$ echo 2345
2345
bash-5.3$ history
     1  echo 1234
     2  echo 2345
     3  echo 13456
     4  echo 21234
     5  history
     6  echo 2345
     7  history
bash-5.3$ exit
$ cat history
echo 1234
echo 2345
echo 3456
echo 21234
history
echo 2345
history

It took me a long time to figure this out, and it's completely dependent
on this particular set of data. You have `histappend' set (it's set by
default, but this would happen anyway because you have fewer history lines
added during that shell session than are in the history list). Bash adds
four commands to the history list during this session, starting with the
`echo 21234' (it doesn't know about readline's changes to the history
list). It appends those four commands to the history file, which happens to
leave the `echo 3456' unchanged -- coincidentally the first history entry
changed by moving around the history list and editing.

You don't have revert-all-at-newline set, so history entries are still
modified and still have undo lists at shell exit, and the modified entries
are written out.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to