Passing arguments with parentheses to Scala script contained in windows batch file

I'd like to put some Scala scripts into a batch file. If you just print the arguments, the canonical way would be like this:

::#!
@echo off
scala %0 %*
goto :eof
::!#
args foreach println

(This actually calls another batch script, scala.bat from the bin-directory of Scala). If I try to pass an argument containing parentheses to it, the windows command line interpreter complains with a syntax error:

printargs.bat "foo(bar)baz"

Strangely, if I create a scala file printargs.scala containing just args foreach println, this works correctly:

scala printargs.scala "foo(bar)baz"

So I assume this is not a bug in scala.bat. But what can I do?

Update: the actual error occurs in the following line in scala.bat:

set _ARGS=%*

with the error message

baz was unexpected at this time

If I change scala.bat that it does not use a local variable but use %* directly, it works correctly. So I filed a bug-report. The question remains if there is a workaround for this problem until the bug is fixed.

Answers


This bug does not occur in scala 2.8.1.final. I would suggest using that version instead.


I don't think this has anything to do with Scala.. I'm currently having the same problem with passing an argument which contains parentheses into a grails command. Apparently this is a problem with the windows shell, have tried escaping the characters "(" but that does not work :/


Need Your Help

Things you can draw with HTML tables

html performance drawing html-table

So I was watching a talk by Google's Marissa Mayer about speeding up Google's pages. They found that a shopping cart icon increased load time by 2%, and users then searched 2% less. They managed to