The original code was slightly broken, because the inner tty was -opost
while the outer one has opost set. This meant that the inner tty was
passing newlines through, while the outer turned them to CRLF.
The code also cleans up the idiosyncratic use of isatty -- we are already
getting the termios, so ENOTTY is our isatty check, better ask for
forgiveness than permission.
The original code was slightly broken, because the inner tty was -opost while the outer one has opost set. This meant that the inner tty was passing newlines through, while the outer turned them to CRLF.
The code also cleans up the idiosyncratic use of isatty -- we are already getting the termios, so ENOTTY is our isatty check, better ask for forgiveness than permission.