Issue #12926 has been updated by Yukihiro Matsumoto.

Assignee set to Nobuyoshi Nakada

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

Matz.

----------------------------------------
Feature #12926: -l flag for line end processing should use chomp! instead of chop! 
https://bugs.ruby-lang.org/issues/12926#change-62553

* Author: Josh Cheek
* Status: Open
* Priority: Normal
* Assignee: Nobuyoshi Nakada
* Target version: 
----------------------------------------
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"
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>