5 ms·
> The terminal just happens to invisibly turn \n into \r\n. No, it was actually done by the Unixen itself, in the part of the kernel that handled ttys: it conv
by Joker_vD 2y ago
> The terminal just happens to invisibly turn \n into \r\n.
No, it was actually done by the Unixen itself, in the part of the kernel that handled ttys: it convert '\n' to '\r\n' on writes to ttys, and '\r' to '\n' on reads from ttys. Linux only recently have moved this functionality out into the user-land layer.
- matheusmoreira 2y ago> in the part of the kernel that handled ttys Yes, that's what I meant. OPOST Enable implementation-defined output processing. That gets set in a termios structure that gets passed to the kernel's terminal subsystem via ioctl. https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/termios.h https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/termbits.h https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/termbits-common.h https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/ioctls.h https://github.com/torvalds/linux/blob/master/include/uapi/a... > Linux only recently have moved this functionality out into the user-land layer. That's certainly news to me. Numerous functions in this file allude to OPOST processing: https://github.com/torvalds/linux/blob/master/drivers/tty/n_tty.c https://github.com/torvalds/linux/blob/master/drivers/tty/n_... If it's not here, where did it move to?
- Joker_vD 2y agoHmmm, I could swear I have read about moving line discipline out of the kernel in some LWN article but apparently no, it never happened (although it probably should've, there is no much reason to perform mapping of NL to CR-NL in the privilleged mode). Maybe I've confused it with what happened on the Windows side of things? They moved almost all of the console infrastructure out of the kernel recently and into the user space, and that definitely has happened.
- matheusmoreira 2y agoI suspect Linux actually can't move it to user space. It would break binary compatibility with all user space code that sets OPOST via the ioctl. They can't hide it in a libc either.