Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy: What's wrong with this "Hello World" program?

Tags:

groovy

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:

  • bash, version "4.2.45(1)-release (x86_64-pc-linux-gnu)"
  • groovy, version 2.1.3
like image 428
Harry Avatar asked Jun 13 '13 03:06

Harry


1 Answers

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.

like image 139
blackdrag Avatar answered Oct 25 '22 02:10

blackdrag