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?

  • found workaround rlwrap seems to fix the problem: askubuntu.com/questions/86905/… – Mark VY Oct 17 '16 at 9: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
  • 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 9 '16 at 21:11

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.