strip end of line CR from show_source

未关闭
#1,037 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
cli

调研方向

从 show_source 的实现入手,使用在 Windows 或 WSL 上采用 CRLF 换行符的 Ruby 源文件重现该问题。跟踪源代码行的读取和显示方式,然后验证 show_source 不再打印末尾的 ^M,同时保留正常的源代码输出。

由索引模型根据 Issue 内容生成。

描述

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>
主要语言
Ruby
星标
477
派生
165
平均合并
1 天 19 小时
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/irb 的其他 Issue

查看 ruby/irb 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。