Skip to content
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

Inserting CR in addition to LF in util.inspect() is not right on UNIX OSes #8163

Closed
alanmimms opened this issue Aug 18, 2016 · 3 comments
Closed
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. util Issues and PRs related to the built-in util module.

Comments

@alanmimms
Copy link

Reproduce with this:

console.log('foo');
console.log(require('util').inspect());

Run this with its output redirected to a file then open that file with, e.g., the Emacs editor. Note the first line has only a LF on the end of it as is traditional for thousands of years in Linux/UNIX OSes. Note that lines containing util.inspect() output end in CRLF, which displays in Emacs as an ugly and wrong ^M on the end of that line.

This behavior of mixing the line ending styles on UNIX OSes will cause all sorts of problems with editors, source code management systems, various text processing utilities, etc. It seems clear that util.inspect() should not unilaterally introduce separate line ending semantics from the rest of the system, or ones that are antithetical to the most common OS node.js runs on.

@addaleax addaleax added the util Issues and PRs related to the built-in util module. label Aug 18, 2016
@addaleax
Copy link
Member

That change is being reverted in #8143, fwiw.

@jasnell
Copy link
Member

jasnell commented Aug 18, 2016

Closing as a duplicate. @alanmimms the fix for this should most likely go out in the next patch release for v6

@jasnell jasnell closed this as completed Aug 18, 2016
@jasnell jasnell added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Aug 18, 2016
@alexindigo
Copy link

I noticed similar behavior without inspect, when console.log outputs multiline objects:

$ nvm exec 6.4 sh -c "node test6.js | wc -c"
Running node v6.4.0 (npm v3.10.3)
     107
$ nvm exec 6.3 sh -c "node test6.js | wc -c"
Running node v6.3.1 (npm v3.10.3)
     102

test6.js:

var obj = {custom: 42, acustom: 'boom', 'aaa': 'bbbb', 'cccc': 'ddddd', 'eeeee': 'ggggg', 'xxxxx': 'yyyyy'};

console.log(obj);

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

4 participants