irb
irb copied to clipboard
strip end of line CR from show_source
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>