diff --git a/lib/irb/command/history.rb b/lib/irb/command/history.rb index 90f87f91023554..e385c66102d230 100644 --- a/lib/irb/command/history.rb +++ b/lib/irb/command/history.rb @@ -14,7 +14,7 @@ class History < Base def execute(arg) - if (match = arg&.match(/(-g|-G)\s+(?.+)\s*\n\z/)) + if (match = arg&.match(/(-g|-G)\s+(?.+)\s*\z/)) grep = Regexp.new(match[:grep]) end diff --git a/test/irb/test_command.rb b/test/irb/test_command.rb index 286fe04769eed5..ec2d1f92df295e 100644 --- a/test/irb/test_command.rb +++ b/test/irb/test_command.rb @@ -972,6 +972,12 @@ def test_history_grep puts x ... EOF + assert_not_include(out, <<~EOF) + foo + EOF + assert_not_include(out, <<~EOF) + bar + EOF assert_empty err end