HBASE-26880 Misspelling commands in hbase shell will crash the shell (#4325)
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
3ae0d9012c
commit
1d8a5bf0e3
|
@ -23,7 +23,7 @@ module IRB
|
|||
|
||||
# Subclass of IRB so can intercept methods
|
||||
class HIRB < Irb
|
||||
def initialize(workspace = nil, input_method = nil)
|
||||
def initialize(workspace = nil, interactive = true, input_method = nil)
|
||||
# This is ugly. Our 'help' method above provokes the following message
|
||||
# on irb construction: 'irb: warn: can't alias help from irb_help.'
|
||||
# Below, we reset the output so its pointed at /dev/null during irb
|
||||
|
@ -46,6 +46,7 @@ module IRB
|
|||
if $stdin.tty?
|
||||
`stty icrnl <&2`
|
||||
end
|
||||
@interactive = interactive
|
||||
super(workspace, input_method)
|
||||
ensure
|
||||
f.close
|
||||
|
@ -117,11 +118,14 @@ module IRB
|
|||
rescue Interrupt => exc
|
||||
rescue SystemExit, SignalException
|
||||
raise
|
||||
rescue Exception
|
||||
rescue NameError => exc
|
||||
raise exc unless @interactive
|
||||
# HBASE-26880: Ignore NameError to prevent exiting Shell on mistyped commands.
|
||||
rescue Exception => exc
|
||||
# HBASE-26741: Raise exception so Shell::exception_handler can catch it.
|
||||
# This modifies this copied method from JRuby so that the HBase shell can
|
||||
# manage the exception and set a proper exit code on the process.
|
||||
raise
|
||||
raise exc
|
||||
end
|
||||
if exc
|
||||
if exc.backtrace && exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
|
||||
|
|
|
@ -213,7 +213,7 @@ workspace = @shell.get_workspace
|
|||
# script calls 'exit' or 'exit 0' or 'exit errcode'.
|
||||
if script2run
|
||||
::Shell::Shell.exception_handler(!full_backtrace) do
|
||||
IRB::HIRB.new(workspace, IRB::HBaseLoader.file_for_load(script2run)).run
|
||||
IRB::HIRB.new(workspace, interactive, IRB::HBaseLoader.file_for_load(script2run)).run
|
||||
end
|
||||
exit @shell.exit_code unless @shell.exit_code.nil?
|
||||
end
|
||||
|
@ -222,5 +222,5 @@ if interactive
|
|||
# Output a banner message that tells users where to go for help
|
||||
@shell.print_banner
|
||||
end
|
||||
IRB::HIRB.new(workspace).run
|
||||
IRB::HIRB.new(workspace, interactive).run
|
||||
exit @shell.exit_code unless interactive || @shell.exit_code.nil?
|
||||
|
|
Loading…
Reference in New Issue