diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-14 13:05:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-14 13:05:52 +0000 |
commit | 9fa0d0058d234ee2d3557761605870a4904840c2 (patch) | |
tree | e3dd695c401cd75c04fb5265fa1f1730b29a9ddc /lib/irb.rb | |
parent | d6dc676d07427e4c1459e9c7509329bb54cbdc7c (diff) | |
download | ruby-9fa0d0058d234ee2d3557761605870a4904840c2.tar.gz |
irb.rb: restore the last error
* lib/irb.rb (eval_input): restore the last error `$!`, as the
previous result. [Feature #14684]
* lib/irb/context.rb (evaluate): add `exception` keyword argument
to set the last error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb.rb')
-rw-r--r-- | lib/irb.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/irb.rb b/lib/irb.rb index 16c03e964f..98bcac016d 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -439,6 +439,8 @@ module IRB # Evaluates input for this session. def eval_input + last_error = nil + @scanner.set_prompt do |ltype, indent, continue, line_no| if ltype @@ -488,7 +490,7 @@ module IRB signal_status(:IN_EVAL) do begin line.untaint - @context.evaluate(line, line_no) + @context.evaluate(line, line_no, exception: last_error) output_value if @context.echo? exc = nil rescue Interrupt => exc @@ -497,6 +499,7 @@ module IRB rescue Exception => exc end if exc + last_error = exc handle_exception(exc) end end |