When I pipe a String to another process, I get an ‘Unmatched quote’ exception - but only if the number of quotes (either ’ or ") within the String is odd:
import scala.language.postfixOps
import scala.sys.process.stringToProcess
val odd = "odd number of 'qu'otes' - this does not work"
s"""echo $odd""" #| "cat -" !
scala.sys.process.Parser$ParseException: Unmatched quote
at scala.sys.process.Parser$.tokenize(Parser.scala:111)
at scala.sys.process.ProcessCreation.apply(Process.scala:95)
at scala.sys.process.ProcessCreation.apply$(Process.scala:94)
at scala.sys.process.ProcessImplicits.stringToProcess(Process.scala:46)
at scala.sys.process.ProcessImplicits.stringToProcess$(Process.scala:214)
at scala.sys.process.package$.stringToProcess(package.scala:207)
... 31 elided
When the number of quotes is even, it works:
val even = "even number of 'quotes' - this works"
s"""echo $even""" #| "cat -" !
I would assume that Scala (2.13.8 / 3.1.2) does not parse the String, because ist is wrapped with “”". Is this correct?