Prerequisites
The Linux virtual terminal (tty) is an emulation of VT102 - Virtual terminal subsystem source.
The real VT100 (nearly the same as VT102) has the following behavior (I suppose):
- In the LINE mode all typed characters are first transmitted to the computer and then, returned to the terminal. Nothing is displayed on the terminal screen before returning from the host.
- The escape sequences are no exception - they are parsed and executed only after returning from the host. That is, if I want to change the font color to red, I should type
ESC[0;31m
, this sequence goes to the computer, echoed back, VT102 receive this, parse and apply. There is no other way to change the terminal font color (in the LINE mode). I am not sure if the VT102 had different font colors though, but that is an example.
Picture from manual:
Excerpt from manual:
LINE/LOCAL
The LINE/LOCAL feature allows the operator to easily place the terminal in either an ON-LINE or a LOCAL (off-line) condition. When the terminal is on-line (ON-LINE indicator is lit) all characters typed on the keyboard are sent directly to the computer and messages from the computer are displayed on the screen. In the LOCAL condition (LOCAL indicator is lit), the terminal is electrically disconnected from the computer; messages are not sent to or received from the computer; and characters typed on the keyboard are echoed on the screen directly.
Source: VT100 series video terminal technical manual, third Edition, July 1982.
The question
Why does the Linux tty
behave in a different way?
I put the bash
into the sleep mode, so it doesn't interfere, then type Esc[0;31m
and get just plain text, the color haven't changed - so, escape sequence has no effect.
I were ask the similar question couple of years ago - Why i can't send escape sequences from keyboard, but can do it from another tty?, but now I got the knowledge about VT102 Linux subsystem and want to understand why it works this way - not identically to the real hardware terminal in this aspect.
sleep
utility that just sleeps. While that utility is running, just like when any other utility is running in the foreground, the input that you type is buffered. If the utility reads its standard input stream, it would see what you typed, otherwise the shell would get it when the utility terminates. Until something reads what you have typed, it can not be interpreted as a colour-changing escape sequence.bash
is not interfere. "I put the bash into the sleep mode, so it doesn't interfere" - how it can be rephrased to better, while saving sense and clarity? "Disablebash
" - also isn't right.sleep
program to stop thebash
from interfering" - good?