Skip to content

Commit 0057fe4

Browse files
aycabtashuujiiBenKanousemameMSP-Greg
authored
Ruby 2.7 backport about IRB (ruby#2990)
* [ruby/reline] Sort completion list #### Legacy mode: ```console $ irb --legacy irb(main):001:0> l[TAB][TAB] lambda load local_variables loop ``` #### Before this patch: ```console $ irb irb(main):001:0> l[TAB][TAB] local_variables loop lambda load ``` #### After this patch: ```console $ irb irb(main):001:0> l[TAB][TAB] lambda load local_variables loop ``` ruby/reline@6074069c7d * Drop an invalid char as UTF-8 * Add test_completion_with_indent_and_completer_quote_characters This is for 8a70524. * [ruby/irb] Add tests for RubyLex The set_auto_indent method calculates the correct number of spaces for indenting a line. We think there might be a few bugs in this method so we are testing the current functionality to make sure nothing breaks when we address those bugs. Example test failure: ``` 1) Failure: TestIRB::TestRubyLex#test_auto_indent [/Users/Ben/Projects/irb/test/irb/test_ruby_lex.rb:75]: Calculated the wrong number of spaces for: def each_top_level_statement initialize_input catch(:TERM_INPUT) do loop do begin prompt unless l = lex throw :TERM_INPUT if @line == '' else . <10> expected but was <12>. ``` ruby/irb@752d5597ab * [ruby/reline] Degenerate the terminal size to [$LINES, $COLUMNS] if it is unknown This is a workaround for ruby/irb#50 ruby/reline@5725677d1a * [ruby/irb] Fix newline depth with multiple braces This commit fixes the check_newline_depth_difference method to multiple open braces on one line into account. Before this change we were subtracting from the depth in check_newline_depth_difference on every open brace. This is the right thing to do if the opening and closing brace are on the same line. For example in a method definition we have an opening and closing parentheses we want to add 1 to our depth, and then remove it. ``` def foo() end ``` However this isn't the correct behavior when the brace spans multiple lines. If a brace spans multiple lines we don't want to subtract from check_newline_depth_difference and we want to treat the braces the same way as we do `end` and allow check_corresponding_token_depth to pop the correct depth. Example of bad behavior: ``` def foo() [ ] puts 'bar' end ``` Example of desired behavior: ``` def foo() [ ] puts 'bar' end ``` ruby/irb@7dc8af01e0 * text/readline/test_readline.rb - fix skip on Reline (ruby#2743) TestRelineAsReadline#test_input_metachar passes on MinGW * Add "require 'openstruct'" what is forgotten * [ruby/irb] Fix lib name of OpenStruct ruby/irb@1f3a84ab6b * Add load path and require for ruby/ruby * Rescue EOFError If C-d is pressed before IRB is ready, IRB crashes because EOFError occurs. * Complete indented and quoted string correctly def foo ''.upca[TAB] This will be completed to be: def foo ''.upcase The indent was gone. This commit fixes the bug. * [ruby/irb] Fix crashing when multiple open braces per line ruby/irb#55 If we had put multiple open braces on a line the with no closing brace spaces_of_nest array keeps getting '0' added to it. This means that when we pop off of this array we are saying that we should be in position zero for the next line. This is an issue because we don't always want to be in position 0 after a closing brace. Example: ``` [[[ ] ] ] ``` In the above example the 'spaces_of_nest' array looks like this after the first line is entered: [0,0,0]. We really want to be indented 4 spaces for the 1st closing brace 2 for the 2nd and 0 for the 3rd. i.e. we want it to be: [0,2,4]. We also saw this issue with a heredoc inside of an array. ``` [<<FOO] hello FOO ``` ruby/irb@80c69c8272 * Support history-size in .inputrc correctly * Introduce an abstracted structure about the encoding of Reline The command prompt on Windows always uses Unicode to take input and print output but most Reline implementation depends on Encoding.default_external. This commit introduces an abstracted structure about the encoding of Reline. * Remove an unused setting variable * Use Reline.encoding_system_needs if exists * Add tests for vi_insert and vi_add * Implement vi_insert_at_bol and vi_add_at_eol * [ruby/reline] Implement vi_to_next_char ruby/reline@066ecb0a21 * [ruby/reline] Implement vi_prev_char and vi_to_prev_char ruby/reline@0ad3ee63fa * [ruby/readline-ext] Include ruby/assert.h in ruby/ruby.h so that assertions can be there ruby/readline-ext@4d44c12832 * Stop using minitest dependent methods * Skip a test that uses assert_ruby_status if it doesn't exist * Use omit instead of skip * Check DONT_RUN_RELINE_TEST envvar * [ruby/irb] Add newline_before_multiline_output ruby/irb@9eb1801a66 * [ruby/irb] Fix compatibility with rails before 5.2 Rails before 5.2 added Array#append as an alias to Array#<< , so that it expects only one argument. However ruby-2.5 added Array#append as an alias to Array#push which takes any number of arguments. If irb completion is used in `rails c` (for example "IO.<tab>") it fails with: irb/completion.rb:206:in `<<': wrong number of arguments (given 3, expected 1) (ArgumentError) Using Array#push instead of Array#append fixes compatibility. ruby/irb@5b7bbf9c34 * Reline: Use a more robust detection of MinTTY The previous detection per get_screen_size fails when stdout is passed to a pipe. That is the case when running ruby tests in parallel ("-j" switch). In this case Reline believes that it's running on MinTTY and the tests are running with ANSI IOGate instead of the Windows adapter on MINGW. So parallel test results were different to that of a single process. This commit fixes these differencies. The code is taken from git sources and translated to ruby. NtQueryObject() is replaced by GetFileInformationByHandleEx(), because NtQueryObject() is undocumented and is more difficult to use: https://github.com/git-for-windows/git/blob/c5a03b1e29c69f3f06c8fabd92493edb73469176/compat/winansi.c#L558 * Reline: Fix changed test results due to change to UTF-8 on Windows In commit f8ea286 the Reline encoding for native windows console was changed to hardcoded UTF-8. This caused failures in reline and readline tests, but they were hidden, because parallel ruby tests incorrectly used Reline::ANSI as IOGate. Tests failures were raised in single process mode, but not with -j switch. This patch corrects encodings on native Windows console. * [ruby/irb] [ruby/irb] Rewrite an expression to detect multiline ruby/irb@ed5cf375a6 ruby/irb@5b7bbf9c34 * [ruby/reline] Implement vi_change_meta ruby/reline@8538e0e10f * Always refer to Reline::IOGate.encoding * Always use UTF-8 for Reline::GeneralIO on Windows * Use test_mode on Reline::History::Test for encoding * [ruby/reline] Support GNOME style Home/End key sequences [Bug #16510] ruby/reline@788f0df845 * [ruby/irb] Add a new easter egg: dancing ruby ruby/irb@e37dc7e58e * [ruby/irb] Exclude useless files from RDoc ruby/irb@8f1ab2400c * [ruby/irb] Exclude useless files from RDoc * Fix inaccuracy in encoding tests These tests assume Encoding.find('locale') == Encoding.find('external') and fail if they are distinct. * [ruby/reline] Fix Reline::Windows#scroll_down I mistook Right and Bottom. ruby/reline@8be401c5f5 * [ruby/reline] Bypass cursor down when a char is rendered at eol on Windows A newline is automatically inserted if a character is rendered at eol on Windows command prompt. ruby/reline@4bfea07e4a * [ruby/reline] Organize special keys escape sequences ruby/reline@41deb1a3d9 * [ruby/readline-ext] Remove unnecessary -I$(top_srcdir) when it's an individual gem ruby/readline-ext@efaca4a5f4 * [ruby/readline-ext] Check TestRelineAsReadline existance ruby/readline-ext@c0a6303168 * [ruby/readline-ext] The ruby/assert.h is adopted by Ruby 2.7 or later ruby/readline-ext@106c31fc1b * Revert "[ruby/readline-ext] Include ruby/assert.h in ruby/ruby.h so that assertions can be there" This reverts commit 425b206. This cherry-pick was a mistake. * [ruby/readline-ext] Use require check instead of DONT_RUN_RELINE_TEST env ruby/readline-ext@1df99d1481 * [ruby/readline-ext] Add spec.extensions ruby/readline-ext@8c33abb13c * [ruby/readline-ext] Use rake/extensiokntask to build ruby/readline-ext@b0b5f709bd * Fix readline build dependency * [ruby/irb] Add test_complete_symbol ruby/irb@dbbf086c1f * [ruby/irb] Check doc namespace correctly IRB::InputCompletor::PerfectMatchedProc crashes when doc not found because a variable name was incorrect. ruby/irb@889fd4928f * [ruby/irb] Fix auto indent with closed brace A closed brace in auto-indent shouldn't affect the next brace in the same line, but it behaves like below: p() { } It's a bug. ruby/irb@fbe59e344f * [ruby/irb] Use 0.step instead of (..0).each for Ruby 2.5 ruby/irb@5d628ca40e * Revert "[ruby/irb] Add test_complete_symbol" This reverts commit 3af3431. * [ruby/irb] fix reserved words and completion for them ruby/irb@6184b227ad * Add test_complete_symbol The previous version of the test method used a symbol, ":abcdefg" to complete but longer symbols that can be completed are defined by other test methods of other libs. * test/irb/test_completion.rb: suppress a warning: unused literal ignored * [ruby/reline] Use IO#write instead of IO#print IO#print always adds a string of $\ automatically. ruby/reline@a93119c847 * [ruby/irb] Version 1.2.2 ruby/irb@a71753f15a * [ruby/reline] Version 0.1.3 ruby/reline@ea2b182466 * [ruby/irb] Include easter-egg.rb in gemspec `irb` doesn't run because this file isn't included in the gem. ruby/irb@73cda56d25 * [ruby/irb] Version 1.2.3 ruby/irb@dd56e06df5 * support multi-run test for test_readline.rb * [ruby/irb] `yield` outside method definition is a syntax error ruby/irb@dbc7b059c7 * test/readline - allow ENV control of test class creation In ruby/ruby, the tests run on both readline & reline by creating four test classes: ``` TestReadline TestReadlineHistory TestRelineAsReadline TestRelineAsReadlineHistory ``` Reline inports the test files and uses them in its CI. Adding the ENV control allows it to only run the `TestRelineAsReadline` classes. * Omit test_using_quoting_detection_proc_with_multibyte_input temporarily for random order test * support random order test. test_readline: HISTORY should be empty. test_using_quoting_detection_proc: test_using_quoting_detection_proc_with_multibyte_input: Readline.completer_quote_characters= and Readline.completer_word_break_characters= doesn't accept nil, so skip if previous values are nil. * Set Readline.completion_append_character = nil always GNU Readline add a white space when Readline.completion_append_character is not initialized. * Fix a typo [ci skip] * skip test if Reline.completion_proc is nil. Some other tests can set Reline.completion_proc, so if it is nil, simply skip this test. * Reset Reline.point TestRelineAsReadline#test_insert_text expects Readline.point == 0 at the beginning of the test, but a test violate this assumption. * Convert incompatible encoding symbol names * Ignore incompatible convert of symbols * Add workaround for test-bundler failure https://github.com/ruby/actions/runs/500526558?check_suite_focus=true#step:16:127 ``` Failures: 1) Bundler.setup when Bundler is bundled doesn't blow up Failure/Error: expect(err).to be_empty expected `"fatal: not a git repository (or any of the parent directories): .git\nfatal: not a git repository (o...the parent directories): .git\nfatal: not a git repository (or any of the parent directories): .git".empty?` to return true, got false Commands: $ /home/runner/work/actions/actions/snapshot-master/ruby \ -I/home/runner/work/actions/actions/snapshot-master/lib:/home/runner/work/actions/actions/snapshot-master/spec/bundler \ -rsupport/hax -rsupport/artifice/fail \ /home/runner/work/actions/actions/snapshot-master/libexec/bundle install --retry 0 Resolving dependencies... Using bundler 2.1.4 Bundle complete! 1 Gemfile dependency, 1 gem now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git # $? => 0 $ /home/runner/work/actions/actions/snapshot-master/ruby \ -I/home/runner/work/actions/actions/snapshot-master/lib:/home/runner/work/actions/actions/snapshot-master/spec/bundler \ -rsupport/hax -rsupport/artifice/fail \ /home/runner/work/actions/actions/snapshot-master/libexec/bundle exec ruby -e \ require\ \'bundler\'\;\ Bundler.setup fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git # $? => 0 # ./spec/bundler/runtime/setup_spec.rb:1056:in `block (3 levels) in <top (required)>' # ./spec/bundler/spec_helper.rb:111:in `block (3 levels) in <top (required)>' # ./spec/bundler/spec_helper.rb:111:in `block (2 levels) in <top (required)>' # ./spec/bundler/spec_helper.rb:78:in `block (2 levels) in <top (required)>' make: *** [yes-test-bundler] Error 1 ``` * [ruby/irb] Unnamed groups are not captured when named groups are used ruby/irb@0a641a69b0 * [ruby/reline] Work with wrong $/ value correctly ruby/reline@962ebf5a1b * [ruby/irb] Detect multiple lines output simplify The old implementation performance test code: require 'objspace' puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) /\A.*\Z/ !~ ('abc' * 20_000_000) puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) and run `time test.rb`: 2.5868 MB 62.226 MB real 0m1.307s user 0m0.452s sys 0m0.797s The new implementation performance test code: require 'objspace' puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) ('abc' * 20_000_000).include?("\n") puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) and run `time test.rb`: 2.5861 MB 62.226 MB real 0m0.132s user 0m0.088s sys 0m0.042s ruby/irb@40d6610baf * [ruby/reline] Suppress error in case INPUTRC env is empty ruby/reline@bce7e7562b * [ruby/reline] Add yamatanooroti rendering test ruby/reline@f092519525 * [ruby/reline] Rename test suite name of yamatanooroti test ruby/reline@b0f32f5de4 * [ruby/reline] Add a comment why rescue yamatanooroti loading error on the test ruby/reline@2a8061daec * [ruby/irb] Suppress crashing when EncodingError has occurred without lineno ruby/irb@13572d8cdc * [ruby/reline] Suppress error when check ambiguous char width in LANG=C ruby/reline@623dffdd75 * [ruby/io-console] Enable only interrupt bits on `intr: true` ruby/io-console@baaf929041 * [ruby/io-console] bump up to 0.5.4 * [ruby/io-console] Update the minimum requirement of Ruby version ruby/io-console@73e7b6318a * [ruby/io-console] Filter Ruby engine name rather than just /ruby/ This breaks tests using this path on JRuby because the `jruby` executable turns into `jjruby` after the sub. ruby/io-console@e5951aa34c * [ruby/io-console] bump up to 0.5.5 * [ruby/io-console] Prefer keyword arguments ruby/io-console@5facbfc4c8 * [ruby/io-console] [DOC] Improved about `intr:` ruby/io-console@82b630cd79 * [ruby/io-console] Just ignore the extension on other than CRuby ruby/io-console@41b6f09574 * [ruby/io-console] bump up to 0.5.6 Co-authored-by: KOBAYASHI Shuji <shuujii@gmail.com> Co-authored-by: Ben <kanobt61@gmail.com> Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: MSP-Greg <MSP-Greg@users.noreply.github.com> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Kenta Murata <mrkn@mrkn.jp> Co-authored-by: Lars Kanis <lars@greiz-reinsdorf.de> Co-authored-by: Lars Kanis <kanis@comcard.de> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org> Co-authored-by: Nobuhiro IMAI <nov@yo.rim.or.jp> Co-authored-by: Nick Lewis <nick@puppet.com> Co-authored-by: S-H-GAMELINKS <gamelinks007@gmail.com> Co-authored-by: Koichi Sasada <ko1@atdot.net> Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com> Co-authored-by: Charles Oliver Nutter <headius@headius.com>
1 parent ecf874e commit 0057fe4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1169
-260
lines changed

ext/io/console/console.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t *
111111
int argc = *argcp;
112112
rawmode_arg_t *optp = NULL;
113113
VALUE vopts = Qnil;
114+
#ifdef RB_SCAN_ARGS_PASS_CALLED_KEYWORDS
115+
argc = rb_scan_args(argc, argv, "*:", NULL, &vopts);
116+
#else
114117
if (argc > min_argc) {
115118
vopts = rb_check_hash_type(argv[argc-1]);
116119
if (!NIL_P(vopts)) {
@@ -120,6 +123,7 @@ rawmode_opt(int *argcp, VALUE *argv, int min_argc, int max_argc, rawmode_arg_t *
120123
if (!vopts) vopts = Qnil;
121124
}
122125
}
126+
#endif
123127
rb_check_arity(argc, min_argc, max_argc);
124128
if (!NIL_P(vopts)) {
125129
VALUE vmin = rb_hash_aref(vopts, ID2SYM(id_min));
@@ -188,7 +192,7 @@ set_rawmode(conmode *t, void *arg)
188192
#endif
189193
#ifdef ISIG
190194
if (r->intr) {
191-
t->c_iflag |= BRKINT|IXON;
195+
t->c_iflag |= BRKINT;
192196
t->c_lflag |= ISIG;
193197
t->c_oflag |= OPOST;
194198
}
@@ -356,9 +360,9 @@ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter
356360

357361
/*
358362
* call-seq:
359-
* io.raw(min: nil, time: nil) {|io| }
363+
* io.raw(min: nil, time: nil, intr: nil) {|io| }
360364
*
361-
* Yields +self+ within raw mode.
365+
* Yields +self+ within raw mode, and returns the result of the block.
362366
*
363367
* STDIN.raw(&:gets)
364368
*
@@ -370,6 +374,9 @@ ttymode_with_io(VALUE io, VALUE (*func)(VALUE, VALUE), VALUE farg, void (*setter
370374
* The parameter +time+ specifies the timeout in _seconds_ with a
371375
* precision of 1/10 of a second. (default: 0)
372376
*
377+
* If the parameter +intr+ is +true+, enables break, interrupt, quit,
378+
* and suspend special characters.
379+
*
373380
* Refer to the manual page of termios for further details.
374381
*
375382
* You must require 'io/console' to use this method.
@@ -383,11 +390,11 @@ console_raw(int argc, VALUE *argv, VALUE io)
383390

384391
/*
385392
* call-seq:
386-
* io.raw!(min: nil, time: nil)
393+
* io.raw!(min: nil, time: nil, intr: nil) -> io
387394
*
388-
* Enables raw mode.
395+
* Enables raw mode, and returns +io+.
389396
*
390-
* If the terminal mode needs to be back, use io.raw { ... }.
397+
* If the terminal mode needs to be back, use <code>io.raw { ... }</code>.
391398
*
392399
* See IO#raw for details on the parameters.
393400
*
@@ -483,7 +490,7 @@ nogvl_getch(void *p)
483490

484491
/*
485492
* call-seq:
486-
* io.getch(min: nil, time: nil) -> char
493+
* io.getch(min: nil, time: nil, intr: nil) -> char
487494
*
488495
* Reads and returns a character in raw mode.
489496
*
@@ -1490,7 +1497,7 @@ console_dev(int argc, VALUE *argv, VALUE klass)
14901497

14911498
/*
14921499
* call-seq:
1493-
* io.getch(min: nil, time: nil) -> char
1500+
* io.getch(min: nil, time: nil, intr: nil) -> char
14941501
*
14951502
* See IO#getch.
14961503
*/

ext/io/console/extconf.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: false
22
require 'mkmf'
33

4-
ok = true
4+
ok = true if RUBY_ENGINE == "ruby"
55
hdr = nil
66
case
77
when macro_defined?("_WIN32", "")
@@ -14,8 +14,9 @@
1414
%w"stty gtty".each {|f| have_func(f, hdr)}
1515
else
1616
ok = false
17-
end
18-
if ok
17+
end if ok
18+
case ok
19+
when true
1920
have_header("sys/ioctl.h") if hdr
2021
# rb_check_hash_type: 1.9.3
2122
# rb_io_get_write_io: 1.9.1
@@ -27,4 +28,6 @@
2728
create_makefile("io/console") {|conf|
2829
conf << "\n""VK_HEADER = #{vk_header}\n"
2930
}
31+
when nil
32+
File.write("Makefile", dummy_makefile($srcdir).join(""))
3033
end

ext/io/console/io-console.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- ruby -*-
2-
_VERSION = "0.5.3"
2+
_VERSION = "0.5.6"
33
date = %w$Date:: $[1]
44

55
Gem::Specification.new do |s|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Console interface"
1010
s.email = "nobu@ruby-lang.org"
1111
s.description = "add console capabilities to IO instances."
12-
s.required_ruby_version = ">= 2.2.0"
12+
s.required_ruby_version = ">= 2.4.0"
1313
s.homepage = "https://github.com/ruby/io-console"
1414
s.metadata["source_code_url"] = s.homepage
1515
s.authors = ["Nobu Nakada"]

ext/readline/extconf.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,4 @@ def readline.have_type(type)
109109
$defs << "-Drl_hook_func_t=Function"
110110
end
111111

112-
$INCFLAGS << " -I$(top_srcdir)"
113112
create_makefile("readline")

ext/readline/readline-ext.gemspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ Gem::Specification.new do |spec|
88
spec.description = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
99
spec.homepage = "https://github.com/ruby/readline-ext"
1010
spec.license = "BSD-2-Clause"
11+
spec.extensions = %w[ext/readline/extconf.rb]
1112

1213
spec.metadata["homepage_uri"] = spec.homepage
1314
spec.metadata["source_code_uri"] = spec.homepage
1415

1516
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
1718
end
1819
spec.bindir = "exe"
1920
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2021
spec.require_paths = ["lib"]
22+
23+
spec.add_development_dependency "bundler"
24+
spec.add_development_dependency "rake"
25+
spec.add_development_dependency "rake-compiler"
2126
end

lib/benchmark/benchmark.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
# Specify which files should be added to the gem when it is released.
2222
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
2323
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2525
end
2626
spec.bindir = "exe"
2727
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

lib/cgi/cgi.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
1919
spec.metadata["source_code_uri"] = spec.homepage
2020

2121
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2323
end
2424
spec.bindir = "exe"
2525
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

lib/delegate/delegate.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
1919
spec.metadata["source_code_uri"] = spec.homepage
2020

2121
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2323
end
2424
spec.bindir = "exe"
2525
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

lib/getoptlong/getoptlong.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
# Specify which files should be added to the gem when it is released.
2222
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
2323
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2525
end
2626
spec.bindir = "exe"
2727
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

lib/irb.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
require "irb/color"
2222

2323
require "irb/version"
24+
require "irb/easter-egg"
2425

2526
# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
2627
# expressions read from the standard input.
@@ -553,7 +554,8 @@ def eval_input
553554

554555
def handle_exception(exc)
555556
if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
556-
!(SyntaxError === exc)
557+
!(SyntaxError === exc) && !(EncodingError === exc)
558+
# The backtrace of invalid encoding hash (ex. {"\xAE": 1}) raises EncodingError without lineno.
557559
irb_bug = true
558560
else
559561
irb_bug = false
@@ -736,7 +738,13 @@ def prompt(prompt, ltype, indent, line_no) # :nodoc:
736738
end
737739

738740
def output_value # :nodoc:
739-
printf @context.return_format, @context.inspect_last_value
741+
str = @context.inspect_last_value
742+
multiline_p = str.include?("\n")
743+
if multiline_p && @context.newline_before_multiline_output?
744+
printf @context.return_format, "\n#{str}"
745+
else
746+
printf @context.return_format, str
747+
end
740748
end
741749

742750
# Outputs the local variables to this current session, including

0 commit comments

Comments
 (0)