scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

scala.sys.process.Parser fails to tokenize cmd line parameter with trailing backlash #12828

Closed munkki84 closed 11 months ago

munkki84 commented 11 months ago

Reproduction steps

Scala version: 2.13.11

scala> scala.sys.process.Process.apply("abc\\")
java.lang.StringIndexOutOfBoundsException: String index out of range: 5
  at java.lang.String.substring(String.java:1963)
  at scala.sys.process.Parser$.tokenize(Parser.scala:90)
  at scala.sys.process.ProcessCreation.apply(Process.scala:95)
  at scala.sys.process.ProcessCreation.apply$(Process.scala:94)
  at scala.sys.process.Process$.apply(Process.scala:46)
  at scala.sys.process.ProcessCreation.apply(Process.scala:57)§
  at scala.sys.process.ProcessCreation.apply$(Process.scala:57)
  at scala.sys.process.Process$.apply(Process.scala:46)
  ... 32 elided

Problem

When trying to build process with command containing trailing backlash, the built-in tokenizing fails.

som-snytt commented 11 months ago

It is an error but should go through the correct channel.

For the use case (see linked PR), it needs https://github.com/scala/scala/pull/10114 which was reverted because of backslashes on Windows.