-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix windows batch argument probrem. #393
fix windows batch argument probrem. #393
Conversation
the `shift` command of cmd.exe is not shift `%*`. and use delayed-expansion. immediate expansion cause many troubles of special-characters in arguments.
Hi @nazoking, Thank you for your contribution! We really value the time you've taken to put this together. Before we proceed with reviewing this pull request, please sign the Typesafe Contributors License Agreement: |
@@ -15,7 +16,7 @@ set "APP_LIB_DIR=%@@APP_ENV_NAME@@_HOME%\lib\" | |||
|
|||
rem Detect if we were double clicked, although theoretically A user could | |||
rem manually run cmd /c | |||
for %%x in (%cmdcmdline%) do if %%~x==/c set DOUBLECLICKED=1 | |||
for %%x in (!cmdcmdline!) do if %%~x==/c set DOUBLECLICKED=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between %
and !
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!
is delayed-expansion literal. I understood %ENV%
expanded before parse time. !ENV!
after parse time, before run time.
>type test.bat
SET A=%1
if NOT "!A!" == "" echo "OK"
>test a"a
SET A=a"a
The syntax of the command is incorrect.
if NOT "a"a" == "" echo "OK"
SET A=%1
if NOT "!A!" == "" echo "OK"
>test a"a
SET A=a"a
if NOT "!A!" == "" echo "OK"
"OK"
Thanks a lot for this pull request. Can instead of changing the already existing test, create a new one? |
OK. I create new test. |
I tried this on my windows-7 machine. The test fails inside
Means more ore less can syntactically not be processed here |
wmm I tried this on my windows-7 machine. The test success inside cmd.
I added more test fail report on fail. please try and report agin. |
Hm. Same error. I found another one for the normal Error in powershell [info] java.lang.AssertionError: assertion failed:
[info] ---------------------------------
[info] Failed to correctly run the main script!.
[info] "cmd" "/c" "C:\Users\nseiler\AppData\Local\Temp\sbt_b65d6270
-test.bat" ""-Dtest.hoge=\[]!< >%"" "\[]!< >%" "-Dtest.huga="\[]!<>
[info]
[info] --expected----------------------------
[info] arg #0 is [\[]!< >%]
[info] property(test.hoge) is [\[]!< >%]
[info] property(test.huga) is [\[]!<>%]
[info] SUCCESS!
[info]
[info] --found-------------------------------
[info] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info] error code: 1
[info]
[info] --detail-------------------------------
[info] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info]
[info] at scala.Predef$.assert(Predef.scala:179)
[info] at $161c46dea5a88d9febeb$$anonfun$$sbtdef$1.apply(C:\Users\
late\build.sbt:93)
[info] at $161c46dea5a88d9febeb$$anonfun$$sbtdef$1.apply(C:\Users\
late\build.sbt:37)
[info] at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:
[info] at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:
[info] at scala.Function1$$anonfun$compose$1.apply(Function1.scala
[info] at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions
[info] at sbt.std.Transform$$anon$4.work(System.scala:63)
[info] at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Exe
[info] at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Exe
[info] at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
[info] at sbt.Execute.work(Execute.scala:235)
[info] at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
[info] at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
[info] at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(Conc
[info] at sbt.CompletionService$$anon$2.call(CompletionService.sca
[info] at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[info] at java.util.concurrent.Executors$RunnableAdapter.call(Exec
[info] at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[info] at java.util.concurrent.ThreadPoolExecutor.runWorker(Thread
[info] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Threa
[info] at java.lang.Thread.run(Thread.java:724)
[info] [error] (*:checkScript) java.lang.AssertionError: assertion
[info] [error] ---------------------------------
[info] [error] Failed to correctly run the main script!.
[info] [error] "cmd" "/c" "C:\Users\nseiler\AppData\Local\Temp\sbt_
\windows-test.bat" ""-Dtest.hoge=\[]!< >%"" "\[]!< >%" "-Dtest.huga
[info] [error]
[info] [error] --expected----------------------------
[info] [error] arg #0 is [\[]!< >%]
[info] [error] property(test.hoge) is [\[]!< >%]
[info] [error] property(test.huga) is [\[]!<>%]
[info] [error] SUCCESS!
[info] [error]
[info] [error] --found-------------------------------
[info] [error] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info] [error] error code: 1
[info] [error]
[info] [error] --detail-------------------------------
[info] [error] error < ">" kann syntaktisch an dieser Stelle nicht
[info] [error] Total time: 4 s, completed 29.10.2014 22:04:24 Aswell as [info] java.lang.AssertionError: assertion failed:
[info] ---------------------------------
[info] Failed to correctly run the main script!.
[info] "cmd" "/c" "C:\Users\nseiler\AppData\Local\Temp\sbt_9a0da522\test-bat-template\target\universal\stage\bin\windows-test.bat" ""-Dtest.hoge=\[]!<
>%"" "\[]!< >%" "-Dtest.huga="\[]!<>%""
[info]
[info] --expected----------------------------
[info] arg #0 is [\[]!< >%]
[info] property(test.hoge) is [\[]!< >%]
[info] property(test.huga) is [\[]!<>%]
[info] SUCCESS!
[info]
[info] --found-------------------------------
[info] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info] error code: 1
[info]
[info] --detail-------------------------------
[info] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info]
[info] at scala.Predef$.assert(Predef.scala:179)
[info] at $1b0f416a1de260ed5461$$anonfun$$sbtdef$1.apply(C:\Users\nseiler\AppData\Local\Temp\sbt_9a0da522\test-bat-template\build.sbt:93)
[info] at $1b0f416a1de260ed5461$$anonfun$$sbtdef$1.apply(C:\Users\nseiler\AppData\Local\Temp\sbt_9a0da522\test-bat-template\build.sbt:37)
[info] at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
[info] at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
[info] at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[info] at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
[info] at sbt.std.Transform$$anon$4.work(System.scala:63)
[info] at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
[info] at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
[info] at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
[info] at sbt.Execute.work(Execute.scala:235)
[info] at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
[info] at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
[info] at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
[info] at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
[info] at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[info] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[info] at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[info] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[info] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[info] at java.lang.Thread.run(Thread.java:724)
[info] [error] (*:checkScript) java.lang.AssertionError: assertion failed:
[info] [error] ---------------------------------
[info] [error] Failed to correctly run the main script!.
[info] [error] "cmd" "/c" "C:\Users\nseiler\AppData\Local\Temp\sbt_9a0da522\test-bat-template\target\universal\stage\bin\windows-test.bat" ""-Dtest.ho
ge=\[]!< >%"" "\[]!< >%" "-Dtest.huga="\[]!<>%""
[info] [error]
[info] [error] --expected----------------------------
[info] [error] arg #0 is [\[]!< >%]
[info] [error] property(test.hoge) is [\[]!< >%]
[info] [error] property(test.huga) is [\[]!<>%]
[info] [error] SUCCESS!
[info] [error]
[info] [error] --found-------------------------------
[info] [error] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info] [error] error code: 1
[info] [error]
[info] [error] --detail-------------------------------
[info] [error] error < ">" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
[info] [error] Total time: 3 s, completed 29.10.2014 22:10:05
[error] x windows / test-bat-template
[error] {line 4} Command failed: check-script failed
[trace] Stack trace suppressed: run last *:scripted for the full output.
[error] (*:scripted) Failed tests:
[error] windows / test-bat-template
[error] Total time: 37 s, completed 29.10.2014 22:10:06
> |
mm.. the result teach batch is not called... please try scala console (REPL) $ console
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.11.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
scala> sys.process.Process(Seq("cmd","/c","echo -Dtest.huga=\"\\[]!<>\"")).!!
res0: String =
"-Dtest.huga="\[]!<>"
can run this script ( |
[info]
Welcome to Scala version 2.10.2 (Java HotSpot(TM) Client VM, Java 1.7.0_40).
Type in expressions to have them evaluated.
Type :help for more information.
scala> sys.process.Process(Seq("cmd","/c","echo -Dtest.huga=\"\\[]!<>\"")).!!
res0: String =
"-Dtest.huga="\[]!<>"
" seem to work |
m.......... I split test each arguments.please try it.... |
Okay. This must be something with my locale/encoding setup. @jsuereth @kardapoltsev @fiadliel you have any options to validate this PR as well? |
@@ -72,86 +73,60 @@ if "%JAVAOK%"=="false" ( | |||
|
|||
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config. | |||
set _JAVA_OPTS=%JAVA_OPTS% | |||
if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% | |||
if "!_JAVA_OPTS!"=="" set _JAVA_OPTS=!CFG_OPTS! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOH, good catch.
@muuki88 My windows laptop is out of commission temporarily (AC power cord got recalled due to causing fires). Can this wait a few days for the new cord to show up so I can test on an en_US locale? |
Yeah sure. @nazoking was really patient with me until now :-) |
Ok, this looks great, ran the tests. One comment ->
SO, this LGTM to merge and we can issue a fix to the scripted test in a different PR. Sorry this took so long. |
Awesome. @nazoking can you remove the import statement an then we merge this :) |
Thanks you. I remove it. |
…ments fix windows batch argument probrem.
Thanks a lot for your work :) |
merged in |
the
shift
command of cmd.exe is not shift%*
.and use delayed-expansion. immediate expansion cause many troubles of special-characters in arguments.