Skip to content

Commit d6512db

Browse files
committed
Fix EOF in console not being properly handled
1 parent a631b1b commit d6512db

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/mcphackers/mcp/main/MainCLI.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ public MainCLI(String[] args) {
100100
System.out.print(new Ansi().fgBrightCyan().a("> ").fgRgb(255,255,255));
101101
String str = null;
102102
try {
103-
str = consoleInput.nextLine();
103+
if (consoleInput.hasNext()) {
104+
str = consoleInput.nextLine();
105+
} else {
106+
// Only seems to occur during EOF, might occur in other cases?
107+
System.exit(0);
108+
}
104109
} catch (NoSuchElementException ignored) {
105110
}
106111
if (str == null) {

0 commit comments

Comments
 (0)