Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7378

Spaces in JAVA_OPTS env var prevent launching of groovy

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.3
    • Fix Version/s: 2.4.6
    • Component/s: None
    • Labels:
      None
    • Environment:
      Linux
    • Flags:
      Patch

      Description

      Set environment variable JAVA_OPTS to have a system property including spaces/quotes/double-quotes.

      $ export JAVA_OPTS="-Dfoo='bar\" baz\"'"
      $ groovy -e 'println System.getProperty("foo"); println args' 'arg space' "space quote' " "\""

      Expected output would be:
      'bar" baz"'
      [arg space, space quote' , "]

      Actual output is:
      Error: Could not find or load main class baz"'

      I can not comment on proper way to fix startGroovy.bat (assuming it suffers similarly), but included is diff that fixes startGroovy unix script to handle JAVA_OPTS such that quoted arguments are preserved as expected.

      I modeled the attached change which seems to resolve the issue for *nix on the tomcat `catalina.sh run` script block.

      p.s. A concrete use case that bit me was trying to pass java.io.tmpdir to a groovy script to a path that included a space. There are outside reasons that modifying the script to read the desired value and set the system property is not a practical solution.

        Attachments

        1. startGroovy.patch
          1 kB
          Jeffrey Adamson

          Issue Links

            Activity

              People

              • Assignee:
                pascalschumacher Pascal Schumacher
                Reporter:
                jwadamson Jeffrey Adamson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: