From 3864fbc6d85b834be4567fa1d5bd0dccc4dfd808 Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 28 Apr 2020 17:06:43 +0900 Subject: [ruby/irb] Check existence of rc files in irb_info command https://github.com/ruby/irb/commit/cdbb9dfc9f --- lib/irb/cmd/info.rb | 11 +++++------ lib/irb/input-method.rb | 10 +++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/irb/cmd/info.rb b/lib/irb/cmd/info.rb index ddf57b00b4..53ec71d754 100644 --- a/lib/irb/cmd/info.rb +++ b/lib/irb/cmd/info.rb @@ -9,12 +9,11 @@ module IRB def execute Class.new { def inspect - <<~EOM.chomp - Ruby version: #{RUBY_VERSION} - IRB version: #{IRB.version} - InputMethod: #{IRB.CurrentContext.io.inspect} - .irbrc path: #{IRB.rc_file} - EOM + str = "Ruby version: #{RUBY_VERSION}\n" + str += "IRB version: #{IRB.version}\n" + str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n" + str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file) + str end alias_method :to_s, :inspect }.new diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 47fc5db84f..8f337e0eac 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -220,9 +220,11 @@ module IRB # For debug message def inspect - inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' - "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION} and #{inputrc_path}" + str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}" + inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') + str += " and #{inputrc_path}" if File.exist?(inputrc_path) + str end end rescue LoadError @@ -323,12 +325,14 @@ module IRB # For debug message def inspect config = Reline::Config.new + str = "ReidlineInputMethod with Reline #{Reline::VERSION}" if config.respond_to?(:inputrc_path) inputrc_path = config.inputrc_path else inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc') end - "ReidlineInputMethod with Reline #{Reline::VERSION} and #{inputrc_path}" + str += " and #{inputrc_path}" if File.exist?(inputrc_path) + str end end end -- cgit v1.2.3