fun sh add removal of backslash+newline

This commit is contained in:
ansgarz 2021-12-15 18:27:02 +01:00
parent 0f85161df0
commit 0a5640d262

View file

@ -217,7 +217,7 @@ open class Prov protected constructor(
* Empty lines and comments (all text behind # in a line) are supported, i.e. they are ignored. * Empty lines and comments (all text behind # in a line) are supported, i.e. they are ignored.
*/ */
fun sh(script: String, dir: String? = null, sudo: Boolean = false) = def { fun sh(script: String, dir: String? = null, sudo: Boolean = false) = def {
val lines = script.trimIndent().replace("\r\n", "\n").split("\n") val lines = script.trimIndent().replace("\\\n", "").replace("\r\n", "\n").split("\n")
val linesWithoutComments = lines.stream().map { it.split("#")[0] } val linesWithoutComments = lines.stream().map { it.split("#")[0] }
val linesNonEmpty = linesWithoutComments.filter { it.trim().isNotEmpty() } val linesNonEmpty = linesWithoutComments.filter { it.trim().isNotEmpty() }