From 88a84bd98876bba8d95e4ae2f9412273c674d115 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 18 Jan 2021 21:00:08 +0100 Subject: [PATCH] reader: Force ONLCR on for fish and external commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just like OPOST this just breaks output for anything not prepared for it. Fish itself might work with it (and #4505 recommends it), but external commands are broken. You'll see output like foo ⏎ from `echo foo`. Fixes #4873. Continuation of #7133. --- src/reader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/reader.cpp b/src/reader.cpp index 357c0fc17..79135c80a 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -774,6 +774,8 @@ static void term_fix_modes(struct termios *modes) { modes->c_lflag &= ~IEXTEN; // turn off handling of discard and lnext characters modes->c_oflag |= OPOST; // turn on "implementation-defined post processing" - this often // changes how line breaks work. + modes->c_oflag |= ONLCR; // "translate newline to carriage return-newline" - without + // you see staircase output. // Disable flow control in the shell. We don't want to be stopped. modes->c_iflag &= ~IXON; @@ -799,9 +801,10 @@ static void term_fix_modes(struct termios *modes) { } static void term_fix_external_modes(struct termios *modes) { - // Turning off OPOST breaks output (staircase effect), we don't allow it. + // Turning off OPOST or ONLCR breaks output (staircase effect), we don't allow it. // See #7133. modes->c_oflag |= OPOST; + modes->c_oflag |= ONLCR; // These cause other ridiculous behaviors like input not being shown. modes->c_lflag |= ICANON; modes->c_lflag |= IEXTEN;