Browse files

JRUBY-2821: JRuby can't execute files with -q present in file name, o…

…n Windows

Regression tests to be added shortly (in separate revision).

git-svn-id: 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent 8df853c commit 17b8b31e2a9e697894104e0d99205737e4449529 @vvs vvs committed Jul 17, 2008
Showing with 14 additions and 6 deletions.
  1. +14 −6 bin/_jrubyvmopts.bat
@@ -20,11 +20,15 @@ rem Can you believe I'm rewriting batch arg processing in batch files because ba
rem file arg processing sucks so bad? Can you believe this is even possible?
-rem escape any quotes. use -q == ", -_ == '.
+rem Escape any quotes. Use _S for ', _D for ", and _U to escape _ itself.
+rem We have to escape _ itself, otherwise file names with _S and _D
+rem will be converted to to wrong ones, when we un-escape. See JRUBY-2821.
set _ARGS=%*
if not defined _ARGS goto vmoptsDone
-set _ARGS=%_ARGS:'=-_%
-set _ARGS=%_ARGS:"=-q%
+set _ARGS=%_ARGS:_=_U%
+set _ARGS=%_ARGS:'=_S%
+set _ARGS=%_ARGS:"=_D%
rem prequote all args for 'for' statement
set _ARGS="%_ARGS%"
@@ -44,6 +48,9 @@ goto :EOF
if ["%_CMP%"] == [""] goto vmoptsDone
+REM NOTE: If you'd like to use a parameter with underscore in its name,
+REM NOTE: use the quoted value: --do_stuff -> --do_Ustuff
if ["%_CMP%"] == ["--server"] (
set _JAVA_VM=-server
goto :vmoptsNext
@@ -79,9 +86,10 @@ if ["%_CMP%"] == ["--1.8"] (
goto :jvmarg
-rem now unescape -q and -d
-set _CMP=%_CMP:-q="%
-set _CMP=%_CMP:-_='%
+rem now unescape _D, _S and _Q
+set _CMP=%_CMP:_D="%
+set _CMP=%_CMP:_S='%
+set _CMP=%_CMP:_U=_%
set _CMP1=%_CMP:~0,1%
set _CMP2=%_CMP:~0,2%

0 comments on commit 17b8b31

Please sign in to comment.