File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/main/kotlin/kscript/app Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -230,10 +230,16 @@ fun collectDependencies(scriptText: List<String>): List<String> {
230230fun collectRuntimeOptions (scriptText : List <String >): String {
231231 val koptsPrefix = " //KOTLIN_OPTS "
232232
233+ // Append $KSCRIPT_KOTLIN_OPTS.
234+ // Overriding //KOTLIN_OPTS lines in the script relies on the JVM processing
235+ // arguments in order, which seems to be the case for Oracle, OpenJDK, and J9.
236+ val kscriptOpts = System .getenv()[" KSCRIPT_KOTLIN_OPTS" ]
237+
233238 return scriptText.
234239 filter { it.startsWith(koptsPrefix) }.
235- map { it.replace(koptsPrefix, " " ).trim() }.
236- joinToString(" " )
240+ map { it.replaceFirst(koptsPrefix, " " ).trim() }.
241+ joinToString(" " ).
242+ plus( if ( kscriptOpts.isNullOrBlank() ) " " else " ${kscriptOpts} " )
237243}
238244
239245
You can’t perform that action at this time.
0 commit comments