ksh is writing `\0\n` to the terminal rather than `\n` under some circumstances
Red Hat received a bug report (rhbz#1016611) from a customer the content of which is below. The fix outlined in PR #376 is almost certainly just papering over the problem since all it does is change the default for the multiline option from enabled to disabled. Something we don't want to do except for specific terminals where the multiline feature does not work. In which case we should be disabling it only for those environments rather than for everyone.
This issue is to remind us that this problem exists and if someone ever reproduces it we should dig deeper to determine the root cause. It's also possible this has been fixed since the ksh93u+ release in which case this can be closed as early as 2020-01-23 (two years from today) as unreproducible if no one reports seeing this issue.
====
In vi mode when accessing via HP ilo4 virtual serial port, carriage return and newfeed on input do not work properly. The cursor stays on the same line, and sometimes the first few characters of the prompt are missing. Things seem okay in emacs mode and when coming in via ssh or directly via a physical serial port.
strace shows that the new ksh is writing \0\n where the old one just writes \n.
The ksh issue is caused by it writing \0\n instead of just \n. User wrote a kernel probe that intercepts writes and if it finds the new ksh trying to write \0\n it replaces the \0 with a space. With that probe, everything works fine. Without the probe, the problem returns.
Is this ksh or the line discipline on the ILO? ILO terminal emulation is quirky and slow in my experience. I recall that null characters used to be inserted to resolve timing issues on slow terminals (in the 1980s). Any particular stty settings that might cause this?
I just realized that this issue is emblematic of a bug I have already fixed several times in this project. Specifically, the code assumes (incorrectly) it can access bytes adjacent to the buffer. Such as doing the equivalent of buf[-1] = 0;.