Sitelet https://github.com/nodejs/node/issues/8163
Skip to content

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

Description

@alanmimms

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.

Activity

  1. added
    utilIssues and PRs related to the built-in util module.
    on Aug 18, 2016
  2. addaleax commented on Aug 18, 2016

    @addaleax
    Member

    That change is being reverted in #8143, fwiw.

  3. jasnell commented on Aug 18, 2016

    @jasnell
    Member

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

  4. added
    duplicateIssues and PRs that are duplicates of other issues or PRs.
    on Aug 18, 2016
  5. alexindigo commented on Aug 22, 2016

    @alexindigo

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateIssues and PRs that are duplicates of other issues or PRs.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions