Skip to content

strip end of line CR from show_source #1037

@YO4

Description

@YO4

Description

The ruby parser considers CR to be a whitespace character, but IRB does not seem to do that.
This may result in an extra ^M at the end of a line when viewing the source from IRB.

How to reproduce

Save the following source code in CRLF newline on Windows and execute it on WSL.

def desc
  "this file has CRLF newline"
end
binding.irb
$ ruby /mnt/r/crlf.rb

From: /mnt/r/crlf.rb @ line 4 :

    1: def desc^M
    2:   "this file has CRLF newline"^M
    3: end^M
 => 4: binding.irb^M

irb(main):001> show_source "desc"

From: /mnt/r/crlf.rb:1

def desc^M
  "this file has CRLF newline"^M
end^M

=> nil
irb(main):002>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions