1

The documentation for termios says something like this:

ICRNL

Translate carriage return to newline on input (unless IGNCR is set).

OCRNL

Map CR to NL on output.

But what does "on input" and "on output" means exactly? This is what I think:

  • "on input" means when the terminal sends something to the tty device.
  • "on output" means when bash (or any other process) sends something to the tty device.

Am I correct?

  • "On output" means when the kernel sends something to the tty device. E.g. onlcr means translate a newline into CR-LF. So user space only has to worry about writing a newline. When the kernel eventually sends it to the tty, that's when the translation happens. – NickD May 24 '17 at 2:01
1

You need to think of it in terms of a "dumb terminal" (such as a vt100) connected to a serial port on the computer, and looking at it from the perspective of the computer.

So "input" to the computer is when the terminal sends data to the computer; eg when you type on the keyboard.

Similarly "output" is when the computer sends things to terminal; eg when it prints something on the screen.

With a more modern setup (eg a Linux console) we still have the same concepts; "input" is stuff typed on the keyboard, "output" is stuff displayed on the screen.

This matches the standard conventions of "stdin" and "stdout".

|improve this answer|||||
0

That's correct, as far as termios goes, since it's only concerned with the communication between the terminal (a device for displaying characters combined with a device for entering characters) and the host computer.

That "on" may appear awkward, but it's just a short way of saying "in the process of doing input" or "in the process of doing output".

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.