You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Newlines missing carriage returns in REPL, util.inspect() output #7954
I noticed that the repl module and util.inspect() only write \n and not \r\n in their output. readline however consistently writes \r\n to its output.
This seemingly causes output problems with custom REPLs with custom output streams. I'm not exactly sure why this is a problem though, since the output streams eventually reach a (Linux) terminal. The current workaround I have is to create a newline conversion stream (that inserts carriage returns) that then pipes to my actual output stream. However, I'd prefer not to have to use this workaround forever.
This should just be a matter of changing the relevant instances of \n to \r\n in lib/repl.js and lib/util.js.
Well as I said, for some reason \n is not enough for Linux with my custom stream (so os.EOL would not help), I'm not sure why and I haven't really dug into the issue to find out why. Local REPLs work just fine though.
AFAIK using \r\n everywhere should not be a problem, even on non-Windows platforms, and it ensures that the output is displayed correctly.
I'm not sure how you could create a test case to check for visual layout. I think about the best you could do is just to have a test that checks that only \r\n exists in the output and not just \n.
Activity
imyller commentedon Aug 3, 2016
Userland is encouraged to use
os.EOLinstead of hardcoded\nor\r\nfor improved portability.Why not use that in Node.js core libraries?
console,repl,utiletc.mscdex commentedon Aug 3, 2016
Well as I said, for some reason
\nis not enough for Linux with my custom stream (soos.EOLwould not help), I'm not sure why and I haven't really dug into the issue to find out why. Local REPLs work just fine though.AFAIK using
\r\neverywhere should not be a problem, even on non-Windows platforms, and it ensures that the output is displayed correctly.JungMinu commentedon Aug 3, 2016
I will resolve this issue :)
imyller commentedon Aug 3, 2016
So, changing core lib to use
\r\nmasks the real issue. Maybe test case could be created?I agree with that. I use
\r\nuniversally just to be sure.mscdex commentedon Aug 3, 2016
I'm not sure how you could create a test case to check for visual layout. I think about the best you could do is just to have a test that checks that only
\r\nexists in the output and not just\n.JungMinu commentedon Aug 4, 2016
Yep, I will create a pull request ASAP 😄
JungMinu commentedon Aug 13, 2016
#8028 has now landed in fce4b98
repl,util: insert carriage returns in output