diff options
| author | sanfrecce-osaka <yakiyaki_ikayaki@yahoo.co.jp> | 2024-12-29 20:00:08 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-12-29 11:00:11 +0000 |
| commit | 3650f2460f9f58ed188ad289cfb46a1d005d2538 (patch) | |
| tree | 9b8249f25116e876cce40b8c887c60c9cd11b51f | |
| parent | a33c944ba8a0580322ee77b3066755f8e2c1c9b1 (diff) | |
[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
| -rw-r--r-- | lib/irb/command/history.rb | 2 | ||||
| -rw-r--r-- | test/irb/test_command.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/irb/command/history.rb b/lib/irb/command/history.rb index 90f87f9102..e385c66102 100644 --- a/lib/irb/command/history.rb +++ b/lib/irb/command/history.rb @@ -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 diff --git a/test/irb/test_command.rb b/test/irb/test_command.rb index 286fe04769..ec2d1f92df 100644 --- a/test/irb/test_command.rb +++ b/test/irb/test_command.rb @@ -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 |
