diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ShellCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ShellCommand.java index 916ccacff5..fe112f67a5 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ShellCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/ShellCommand.java @@ -159,7 +159,7 @@ public class ShellCommand extends AbstractCommand { launchProcess(args, systemOut, systemErr); } else { - runCommand(args); + runCommand(args, systemOut, systemErr); } } } @@ -238,9 +238,20 @@ public class ShellCommand extends AbstractCommand { ReflectionUtils.invokeMethod(PROCESS_BUILDER_INHERIT_IO_METHOD, processBuilder); } - private void runCommand(List args) { + private void runCommand(List args, PrintStream systemOut, + PrintStream systemErr) { if (!getName().equals(args.get(0))) { - this.springCli.runAndHandleErrors(args.toArray(new String[args.size()])); + PrintStream out = System.out; + PrintStream err = System.err; + System.setOut(systemOut); + System.setErr(systemErr); + try { + this.springCli.runAndHandleErrors(args.toArray(new String[args.size()])); + } + finally { + System.setOut(out); + System.setErr(err); + } } }