You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/03/22 17:02:46 UTC

[groovy] branch GROOVY_4_0_X updated: GROOVY-10541: groovysh can not launch when running on Oracle Linux 8.5(ARM)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new 58e0b44  GROOVY-10541: groovysh can not launch when running on Oracle Linux 8.5(ARM)
58e0b44 is described below

commit 58e0b4471b61702194c677a5a01a0e2c7f3d281f
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Mar 23 00:24:16 2022 +0800

    GROOVY-10541: groovysh can not launch when running on Oracle Linux 8.5(ARM)
    
    (cherry picked from commit a2b1157dd1c22fc5fb1cea97fa76a77cba6d51f8)
---
 .../groovy/org/apache/groovy/groovysh/Main.groovy     | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
index a36ffce..4558a52 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
@@ -20,6 +20,8 @@ package org.apache.groovy.groovysh
 
 import groovy.cli.internal.CliBuilderInternal
 import groovy.cli.internal.OptionAccessor
+import groovy.transform.CompileDynamic
+import groovy.transform.CompileStatic
 import jline.TerminalFactory
 import jline.UnixTerminal
 import jline.UnsupportedTerminal
@@ -47,6 +49,7 @@ import static org.apache.groovy.util.SystemUtil.setSystemPropertyFrom
  *
  * Main CLI entry-point for <tt>groovysh</tt>.
  */
+@CompileStatic
 class Main {
     final Groovysh groovysh
 
@@ -70,6 +73,7 @@ class Main {
      * create a Main instance, configures it according to CLI arguments, and starts the shell.
      * @param main must have a Groovysh member that has an IO member.
      */
+    @CompileDynamic
     static void main(final String[] args) {
         MessageSource messages = new MessageSource(Main)
         def cli = new CliBuilderInternal(usage: 'groovysh [options] [...]', stopAtNonOption: false,
@@ -231,11 +235,15 @@ class Main {
                 // Should never happen
                 throw new IllegalArgumentException("Invalid Terminal type: $type")
         }
+
+        Ansi.enabled = false
         if (enableAnsi) {
-            installAnsi() // must be called before IO(), since it modifies System.in
-            Ansi.enabled = !suppressColor
-        } else {
-            Ansi.enabled = false
+            try {
+                installAnsi() // must be called before IO(), since it modifies System.in
+                Ansi.enabled = !suppressColor
+            } catch (Throwable t) {
+                LOGGER.warning("ansi will be disabled because an error occurred while installing ansi: " + t.getMessage())
+            }
         }
 
         if (type != null) {
@@ -256,5 +264,6 @@ class Main {
     static void setSystemProperty(final String nameValue) {
         setSystemPropertyFrom(nameValue)
     }
-}
 
+    private static final java.util.logging.Logger LOGGER = java.util.logging.Logger.getLogger(Main.class.getName());
+}