ruby / ruby/irb

strip end of line CR from show_source

Open
#1,037 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
478
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
12

Description

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>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the show_source implementation and reproduce the issue with a Ruby source file using CRLF newlines on Windows or WSL. Trace how source lines are read and displayed, then verify that show_source no longer prints a trailing ^M while preserving normal source output.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.