Project

General

Profile

Feature #12926

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

Added by josh.cheek (Josh Cheek) almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
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"

Associated revisions

Revision af9a151f
Added by nobu (Nobuyoshi Nakada) over 2 years ago

parse.y: chomp by -l

  • parse.y (rb_parser_while_loop): should chomp but not chop by -l option. [ruby-core:78099] [Bug #12926]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57373
Added by nobu (Nobuyoshi Nakada) over 2 years ago

parse.y: chomp by -l

  • parse.y (rb_parser_while_loop): should chomp but not chop by -l option. [ruby-core:78099] [Bug #12926]

Revision 57373
Added by nobu (Nobuyoshi Nakada) over 2 years ago

parse.y: chomp by -l

  • parse.y (rb_parser_while_loop): should chomp but not chop by -l option. [ruby-core:78099] [Bug #12926]

Revision 57373
Added by nobu (Nobuyoshi Nakada) over 2 years ago

parse.y: chomp by -l

  • parse.y (rb_parser_while_loop): should chomp but not chop by -l option. [ruby-core:78099] [Bug #12926]

History

Updated by matz (Yukihiro Matsumoto) over 2 years ago

  • Assignee set to nobu (Nobuyoshi Nakada)

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

Matz.

#3

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset r57373.


parse.y: chomp by -l

  • parse.y (rb_parser_while_loop): should chomp but not chop by -l option. [ruby-core:78099] [Bug #12926]

Also available in: Atom PDF