Skip to content

Commit

Permalink
Fix stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Jan 22, 2014
1 parent 04e2872 commit 92f0aa1
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -92,7 +94,6 @@ public Result execute(UIExecutionContext context) throws Exception
{
List<Result> results = new ArrayList<>();
Resource<?> currentResource = (Resource<?>) context.getUIContext().getInitialSelection().get();
Shell shell = (Shell) context.getUIContext().getProvider();

ALL: for (String path : arguments.getValue())
{
Expand All @@ -101,13 +102,15 @@ public Result execute(UIExecutionContext context) throws Exception
{
if (resource.exists())
{
PipedOutputStream stdin = new PipedOutputStream();
final PipedOutputStream stdin = new PipedOutputStream();
final ByteArrayOutputStream stdout = new ByteArrayOutputStream();
final ByteArrayOutputStream stderr = new ByteArrayOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));

Shell scriptShell = shellFactory.createShell((File) resource.getParent().getUnderlyingResourceObject(),
new SettingsBuilder().inputStream(new PipedInputStream(stdin))
.outputStream(shell.getConsole().getShell().out())
.outputStreamError(shell.getConsole().getShell().err()).create());
.outputStream(new PrintStream(stdout))
.outputStreamError(new PrintStream(stderr)).create());

BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getResourceInputStream()));

Expand All @@ -123,6 +126,9 @@ public Result execute(UIExecutionContext context) throws Exception

results.add(result);

context.getUIContext().getProvider().getOutput().out().write(stdout.toByteArray());
context.getUIContext().getProvider().getOutput().err().write(stderr.toByteArray());

if (result instanceof Failed)
break ALL;
}
Expand Down

0 comments on commit 92f0aa1

Please sign in to comment.