I'd like to compile a bash script from within Scala. To ease this I'd like to use string interpolation. However bash variables and Scala string interpolation don't seem to play well with each other. Here's an example
val someFile="test.txt"
val bashScript = s"""
newFile=${someFile}.filtered
grep foobar $someFile > $newFile
"""
This will result in a compile error because $newFile can not be interpolated. However, literally keeping $newFile as it is would give the expected valid bash script.
Possible solutions have crossed my mind, but I don't know if they are feasible nor how to implement them
Tell scala to use a different prefix for the interpolated expression, e.g. by implementing a custom interpolator
Somehow ignore non-interpolatable expressions and keep them as they are.