From: nobu@... Date: 2016-11-23T01:14:30+00:00 Subject: [ruby-core:78268] [Ruby trunk Feature#12926] -l flag for line end processing should use chomp! instead of chop! Issue #12926 has been updated by Nobuyoshi Nakada. I'd consider it a bug. https://github.com/nobu/ruby/tree/bug/12926-chomp-l ---------------------------------------- Feature #12926: -l flag for line end processing should use chomp! instead of chop! https://bugs.ruby-lang.org/issues/12926#change-61634 * Author: Josh Cheek * Status: Open * Priority: Normal * Assignee: ---------------------------------------- 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: