[ruby/irb] Fix broken history command with -g

(https://github.com/ruby/irb/pull/1057)

Local variable `grep` was always nil because the regular expression parsing options contained an unnecessary `\n`. `test_history_grep` did not detect this because it only asserted what was included in the output.

https://github.com/ruby/irb/commit/a282bbc0cf
This commit is contained in:
sanfrecce-osaka 2024-12-29 20:00:08 +09:00 committed by git
parent a33c944ba8
commit 3650f2460f
2 changed files with 7 additions and 1 deletions

View File

@ -14,7 +14,7 @@ module IRB
def execute(arg)
if (match = arg&.match(/(-g|-G)\s+(?<grep>.+)\s*\n\z/))
if (match = arg&.match(/(-g|-G)\s+(?<grep>.+)\s*\z/))
grep = Regexp.new(match[:grep])
end

View File

@ -972,6 +972,12 @@ module TestIRB
puts x
...
EOF
assert_not_include(out, <<~EOF)
foo
EOF
assert_not_include(out, <<~EOF)
bar
EOF
assert_empty err
end