Fix capturing CTRL-C to exit the shell.

Fixes #195
This commit is contained in:
Eric Bottard
2018-01-17 19:04:57 +01:00
parent 793eaa6fe7
commit ea71c3821b
2 changed files with 5 additions and 2 deletions

View File

@@ -119,12 +119,15 @@ public class Shell implements CommandRegistry {
*/
public void run(InputProvider inputProvider) throws IOException {
Object result = null;
while (!(result instanceof ExitRequest)) {
while (!(result instanceof ExitRequest)) { // Handles ExitRequest thrown from Quit command
Input input;
try {
input = inputProvider.readInput();
}
catch (Exception e) {
if (e instanceof ExitRequest) { // Handles ExitRequest thrown from hitting CTRL-C
break;
}
resultHandler.handleResult(e);
continue;
}

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.1.BUILD-SNAPSHOT</version>
</parent>
<description>Examples of using Spring Shell 2</description>