Project

General

Profile

Actions

Feature #12926

closed

-l flag for line end processing should use chomp! instead of chop!

Added by josh.cheek (Josh Cheek) about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:78099]

Description

Using chop! can mess up the final line of input because it may not end in a line-end character.

printf a\\nb\\nc | ruby -lne 'p $_'
"a"
"b"
""


$ printf a\\nb\\nc\\n | ruby -lne 'p $_'
"a"
"b"
"c"

Using chomp! works correctly in both cases.

$ printf a\\nb\\nc | ruby -ne '$_.chomp!; p $_'
"a"
"b"
"c"

$ printf a\\nb\\nc\\n | ruby -ne '$_.chomp!; p $_'
"a"
"b"
"c"

Updated by matz (Yukihiro Matsumoto) almost 8 years ago

  • Assignee set to nobu (Nobuyoshi Nakada)

OK, accepted
This is because -l is older than chomp.

Matz.

Actions #3

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Status changed from Open to Closed

Applied in changeset r57373.


parse.y: chomp by -l

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0