Commit 57ba6a40 authored by Dave Syer's avatar Dave Syer

Divert out/err streams while command runs

Actually System.in works fine, it's the output streams that get buffered.
We can fix it by diverting them for the duration of the command.

Fixes gh-217
parent 6b6bd379
......@@ -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<String> args) {
private void runCommand(List<String> 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);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment