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

Spaces in JAVA_OPTS env var prevent launching of groovy

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.3
    • 2.4.6
    • None
    • None
    • Linux
    • 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

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment