summaryrefslogtreecommitdiff
path: root/lib/irb.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb.rb')
-rw-r--r--lib/irb.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index bcd6599af9..ee6979c6d0 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -21,6 +21,7 @@ require "irb/locale"
require "irb/color"
require "irb/version"
+require "irb/easter-egg"
# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
# expressions read from the standard input.
@@ -553,7 +554,8 @@ module IRB
def handle_exception(exc)
if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
- !(SyntaxError === exc)
+ !(SyntaxError === exc) && !(EncodingError === exc)
+ # The backtrace of invalid encoding hash (ex. {"\xAE": 1}) raises EncodingError without lineno.
irb_bug = true
else
irb_bug = false
@@ -736,7 +738,13 @@ module IRB
end
def output_value # :nodoc:
- printf @context.return_format, @context.inspect_last_value
+ str = @context.inspect_last_value
+ multiline_p = str.include?("\n")
+ if multiline_p && @context.newline_before_multiline_output?
+ printf @context.return_format, "\n#{str}"
+ else
+ printf @context.return_format, str
+ end
end
# Outputs the local variables to this current session, including