joshelser commented on a change in pull request #4101:
URL: https://github.com/apache/hbase/pull/4101#discussion_r802141273



##########
File path: hbase-shell/src/main/ruby/irb/hirb.rb
##########
@@ -56,6 +56,108 @@ def output_value
       # after all output.
       super unless @context.last_value.nil?
     end
+
+    # Copied from irb.rb and overrides the rescue Exception block so the
+    # Shell::exception_handler can deal with the exceptions.
+    def eval_input
+      @scanner.set_prompt do
+      |ltype, indent, continue, line_no|
+        if ltype
+          f = @context.prompt_s
+        elsif continue
+          f = @context.prompt_c
+        elsif indent > 0
+          f = @context.prompt_n
+        else
+          f = @context.prompt_i
+        end
+        f = "" unless f
+        if @context.prompting?
+          @context.io.prompt = p = prompt(f, ltype, indent, line_no)
+        else
+          @context.io.prompt = p = ""
+        end
+        if @context.auto_indent_mode
+          unless ltype
+            ind = prompt(@context.prompt_i, ltype, indent, 
line_no)[/.*\z/].size +
+              indent * 2 - p.size
+            ind += 2 if continue
+            @context.io.prompt = p + " " * ind if ind > 0
+          end
+        end
+      end
+
+      @scanner.set_input(@context.io) do
+        signal_status(:IN_INPUT) do
+          if l = @context.io.gets
+            print l if @context.verbose?
+          else
+            if @context.ignore_eof? and @context.io.readable_after_eof?
+              l = "\n"
+              if @context.verbose?
+                printf "Use \"exit\" to leave %s\n", @context.ap_name
+              end
+            else
+              print "\n"
+            end
+          end
+          l
+        end
+      end
+
+      @scanner.each_top_level_statement do |line, line_no|
+        signal_status(:IN_EVAL) do
+          begin
+            line.untaint
+            @context.evaluate(line, line_no)
+            output_value if @context.echo?
+            exc = nil
+          rescue Interrupt => exc
+          rescue SystemExit, SignalException
+            raise
+          rescue Exception
+            # Raise exception so Shell::exception_handler can catch it.

Review comment:
       ```suggestion
               # 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.
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to