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 开发者_StackOverflowit 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.
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 :/
精彩评论