New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OTP 26 interprets CR ("\r"
) from standard_io
as a line delimiter ("\n"
).
#8360
Comments
It was not intentional, though I'm still on the fence about whether it is desirable or not. The problem is that we do not know if the what is writing to stdin is a pipe (as in your example) or just a very dumb terminal. If it is a pipe, then the old behaviour is correct, but if it is a very dumb terminal then the new behaviour is better. Given that today it is very uncommon to have very dumb terminals I'm leaning towards calling this a bug and that we should not translate a single |
A bit of additional context, I came about this behavior working on the Lexical language server. There's a weird bug where the language server misinterprets LSP messages, which are delimited with Nominally, However when VSCode's under an exceptional amount of load, such as replacing references across 100+ files, it seems to "miss" one of the delimiters, leading a bad offset in reading the protocol. My working theory is that:
The consequence is that the language client more slowly writes All that considered, I'm inclined to agree with your take. |
For what it's worth. |
The line that causes this bug is this: https://github.com/erlang/otp/blob/master/lib/kernel/src/group.erl#L1003 The comment above references "Advanced Programming in the Unix Environment, 2nd ed, Stevens, page 638", if anyone has that maybe we can find an answer as to why it is done this way :) A possibly simple fix for the problem of data being sent as |
That chapter describes special characters, which of them can have their meaning changed, and has this bit about CR:
It might be more of a reference to the table listing and describing special characters in this same chapter, than to the behavior of CR. I don't know. This stuff goes over my head. |
[@essen beat me to it] My understanding of The comment simply states that it ignores |
I did an attempt att fixing this in #8396, would be great if you could test it and see if it solves your problem. Still need to write some tests before merging. |
Fix merged to master |
Describe the bug:
OTP 26 treats singular CR (
"\r"
) characters fromstandard_io
as line delimiters, whereas OTP 25 and earlier versions do not.unicode
orlatin1
(raw) encoding.IO.binread(:standard_io, 1)
(:file.read/2
within).To Reproduce:
I've made a small repository to reproduce the bug here: https://github.com/Moosieus/crlf_test.
Expected behavior
In the test repo, given the input
"Line #1\rLine #2\n"
on stdin, reading a line in OTP 26 yields:whereas OTP 25 yields:
I suppose the expected behavior here's open to discussion. Is the change in behavior intentional and/or desirable?
Affected versions
OTP 26.
The text was updated successfully, but these errors were encountered: