Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.3
-
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
Attachments
Issue Links
- relates to
-
GROOVY-4910 groovy.bat fails when the JAVA_OPTS contains space characters
- Closed