1

I'm using the Windows Subsystem for Linux; I don't know if this is relevant. Anyway, suppose I'm running cat at a terminal, and I enter 2.718\te where \t is an actual tab character. The screen now looks like this: 2.718 e. Now I realize I made a mistake, and I should give a few more digits of precision. (Whatever, this example is made up. The point is that I make mistakes when typing.) This should be easy: my keyboard has a backspace key :) I hit it once, and the e disappears. So far so good. I hit it again and ... one space disappears. I hit it one more time, and one more space disappears, even though by now I should have erased the 8. I now press enter, and cat echoes back at me... 2.71. So, apparently, I did erase the 8, but the contents of my screen got de-synched from the ground truth in the terminal driver.

So, my question is why. More importantly, what to do about it?

Mark VY
  • 113
  • 4
  • found workaround rlwrap seems to fix the problem: http://askubuntu.com/questions/86905/how-to-have-editing-capabilities-in-command-line-apps-that-do-not-provide-them/86908 – Mark VY Oct 17 '16 at 09:01
  • 1
    Apparently, your tab is expanded to 8 spaces instead of a \t character. You can check this by saving the output to a file and running od -c file. You should see that there are spaces there and not a \t. – terdon Oct 17 '16 at 10:45
  • I thought of that. I tried cat > t.txt, followed by wc. It is NOT being expanded to spaces. – Mark VY Oct 17 '16 at 18:32
  • Hmm, maybe the readline implementation on Windows does so then. Could you confirm with cat file | od - c, just in case though? – terdon Oct 17 '16 at 20:10
  • od says it's \t – Mark VY Oct 18 '16 at 04:46
  • 1
    canonical mode terminal input doesn't involve readline, and this should probably be filed as a bug on the GitHub bug tracker for WSL. – JdeBP Nov 09 '16 at 21:11
  • JdeBP: thank you, I should have thought of that! – Mark VY Nov 10 '16 at 07:25

0 Answers0