Unexpected indentation behaviour when I set the terminal to raw mode – why is this happening?

Based on what I have read, when a terminal is in raw mode, the characters are not processed by the terminal driver, but are sent straight through.

I set the terminal in raw mode using the command stty raw, and I noticed that the output is indented to the right each time until there is no more room. This is what I mean:

enter image description here

Why is this behavior happening?!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

One of the stty settings (onlcr) tells the terminal driver to convert newline (which is actually ASCII line-feed) to carriage-return plus line-feed.

Unix-like systems just write a newline to end lines, letting the terminal driver do the right thing (convert newline to carriage-return plus line-feed).

Carriage-return “goes left” and line-feed “goes down”.

When you set the terminal to raw mode, newline will no longer be converted to carriage-return plus line-feed. Lacking the carriage-returns, you get that staircase effect.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x