jline / jline2

Jline 2.x
http://jline.github.com/jline2/
Other
713 stars 182 forks source link

jline prints a CRLF on macOS and Linux for a new line #282

Closed chrisseaton closed 7 years ago

chrisseaton commented 7 years ago

Console reader's println is

    public void println() throws IOException {
        tputs("carriage_return");
        rawPrint('\n');
    }

UnixTerminal has carriage_return as ^M, which is CR, and then you rawPrint the LF.

Isn't CRLF a Windows thing? Why do you print it here? Is UnixTerminal getting confused somehow? I'm redirecting stdout to a file in my shell if that makes a difference.

I've seen this happening on macOS and Linux, but on some colleagues Linux machines they seem to be getting just LF.

eregon commented 7 years ago

This is a regression between JLine 2.11 (working) and JLine 2.14.3 (contains this bug).

This is the reason why some Linux machines behaved as expected: they were using the older JLine.

gnodet commented 7 years ago

I think it should use the System.lineSeparator() instead. Could someone provide a PR ?

eregon commented 7 years ago

Bisecting reveals commit 3b0c474af7b46245109487083f1c0a0fd053165e introduced the extra \r. I'll try to make a PR.

eregon commented 7 years ago

PR created, with test and ensuring it fails before and succeeds after the fix: #283 .