Reputation: 3937
This does not work:
$ groovy -e 'println "Hello, world!"'
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script_from_command_line: 1: unexpected char: 0xFFFF @ line 1, column 23.
println "Hello, world!
^
1 error
However, putting a space between the last double- and single-quote works...
$ # groovy -e 'println "Hello, world!"'
$ groovy -e 'println "Hello, world!" '
Hello, world!
... even though bash
seems to be able to correctly handle the trailing "'
pair (i.e., without any intervening space) as follows:
$ echo '"Hello, world!"'
"Hello, world!"
Also, parenthesizing the println
argument works just fine:
$ groovy -e 'println ("Hello, world!")'
Hello, world!
Now, I would like to know why the very first case does not work.
I'm using:
Upvotes: 15
Views: 12363
Reputation: 203
This runs fine on OSX. I think this error has to do with improper termination. The following runs on linux:
groovy -e 'println "Hello, world!";'
Upvotes: -2
Reputation: 6518
As BDKosher already stated, this is a bug from Apache Commons CLI. Groovy wants to update to 1.3, but the CLI folks take their time with that version and it contains incompatibilities.
And as I wrote in an above comment already 0xFFFF is used by antlr to show the end of the file, it does not have to be a valid unicode character for that. The wording was criticized because of this, but the wording is from the parser generator antlr, not from us.
Upvotes: 4
Reputation: 366
I see an exception running version 2.1.3 and Java 6:
C:\Users\mwest>groovy -e 'println "Hello, world!"'
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script_from_command_line: 1: expecting ''', found '<EOF>' @ line 1, column 9.
'println
Curiously reversing the quotes works
C:\Users\mwest>groovy -e "println 'Hello, world!'"
Hello, world!
Upvotes: 0