@@ -23,7 +23,7 @@ module IRB
2323
2424 # Subclass of IRB so can intercept methods
2525 class HIRB < Irb
26- def initialize ( workspace = nil , input_method = nil )
26+ def initialize ( workspace = nil , interactive = true , input_method = nil )
2727 # This is ugly. Our 'help' method above provokes the following message
2828 # on irb construction: 'irb: warn: can't alias help from irb_help.'
2929 # Below, we reset the output so its pointed at /dev/null during irb
@@ -46,6 +46,7 @@ def initialize(workspace = nil, input_method = nil)
4646 if $stdin. tty?
4747 `stty icrnl <&2`
4848 end
49+ @interactive = interactive
4950 super ( workspace , input_method )
5051 ensure
5152 f . close
@@ -117,11 +118,14 @@ def eval_input
117118 rescue Interrupt => exc
118119 rescue SystemExit , SignalException
119120 raise
120- rescue Exception
121+ rescue NameError => exc
122+ raise exc unless @interactive
123+ # HBASE-26880: Ignore NameError to prevent exiting Shell on mistyped commands.
124+ rescue Exception => exc
121125 # HBASE-26741: Raise exception so Shell::exception_handler can catch it.
122126 # This modifies this copied method from JRuby so that the HBase shell can
123127 # manage the exception and set a proper exit code on the process.
124- raise
128+ raise exc
125129 end
126130 if exc
127131 if exc . backtrace && exc . backtrace [ 0 ] =~ /irb(2)?(\/ .*|-.*|\. rb)?:/ && exc . class . to_s !~ /^IRB/ &&
0 commit comments