REPL: Fix crash on trying to :load with incorrect filename (KT-12037)
(cherry picked from commit 0238575a36beec36c412862ded8abcad02ab4c1f)
This commit is contained in:
committed by
Yan Zhulanow
parent
a25e93d82a
commit
46c2adda4e
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.cli.jvm.repl.messages.unescapeLineBreaks
|
|||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
@@ -140,8 +141,12 @@ class ReplFromTerminal(
|
|||||||
}
|
}
|
||||||
else if (split.size >= 2 && split[0] == "load") {
|
else if (split.size >= 2 && split[0] == "load") {
|
||||||
val fileName = split[1]
|
val fileName = split[1]
|
||||||
val scriptText = FileUtil.loadFile(File(fileName))
|
try {
|
||||||
eval(scriptText)
|
val scriptText = FileUtil.loadFile(File(fileName))
|
||||||
|
eval(scriptText)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
writer.outputCompileError("Can not load script: ${e.message}")
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user