0

Sometimes, when I invoke history in bash, it starts printing normally, and at some point switches to garbled characters:

history screenshot

Oddly, when I copy that from my terminal and paste it here, the characters are different:

19955  ssh somehost-bacc
19956  ssh-keygen -R somehost-bacc
19957  ssh somehost-bacc
19958  ssh otherhost-bacc
19959  

19960  __h +_+-+e_+-bacc
19961  d_y +_+-+e_+-bacc
19962  dia+--b _bc+c-_dc-2-c+c
19963  d_y _bc+c-_dc-2-c+c

My prompt and everything are garbled after that, until I reset.

Looking around in .bash_history in Vim or less, that line shows as ^L^N^U. I definitely didn't just press Ctrl+LNU at the prompt then.

The first time this happened, I deleted that line, and history printed normally afterward. This is the second time it's happened, and I want to know why, and how to avoid it.

Context:
Bash 4.2.46(2)-release on CentOS 7.7.1908
SecureCRT 8.3.4 on Windows 10 1909

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Jacktose
  • 441
  • In SecureCRT, I have Terminal emulation: XTerm; Character encoding: UTF-8. If I change Terminal to ANSI, it fixes this problem, but the appearance of Vim is all screwed up. – Jacktose Apr 13 '20 at 18:34
  • 1
    There's an explanation of the terminal behaviour at https://unix.stackexchange.com/a/506140/5132 , so I am assuming that this question is asking how those control characters keep getting into your shell's command history. – JdeBP Apr 14 '20 at 10:55
  • Yes, I mostly want to know how it happened and how to stop it. (I am curious about the mechanism, but I'm not sure I want to go farther down that rabbit hole than “bad characters make text go oopsie.”) – Jacktose Apr 14 '20 at 16:32
  • stty reset will fix it. You have sent your terminal ASCII Control Characters including ^N and ^O. See http://ascii-table.com/control-chars.php – waltinator Apr 14 '20 at 23:09

0 Answers0