Skip to content

Commit

Permalink
Reformat condition
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed May 26, 2022
1 parent 5561033 commit b9e9375
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions src/launcher/java/org/truffleruby/launcher/RubyLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,33 +188,29 @@ protected boolean parseCommonOption(String defaultOptionPrefix, Map<String, Stri

@Override
protected boolean runLauncherAction() {
if (!helpOptionUsed || System.console() == null) {
return super.runLauncherAction();
}

String pager = getPagerFromEnv();
if (pager.isEmpty()) {
String pager;
if (helpOptionUsed && System.console() != null && !(pager = getPagerFromEnv()).isEmpty()) {
try {
Process process = new ProcessBuilder(pager)
.redirectOutput(Redirect.INHERIT)
.redirectErrorStream(true)
.start();
PrintStream out = new PrintStream(process.getOutputStream());

setOutput(out);
boolean code = super.runLauncherAction();

out.flush();
out.close();
process.waitFor();

return code;
} catch (IOException | InterruptedException e) {
throw abort(e);
}
} else {
return super.runLauncherAction();
}

try {
Process process = new ProcessBuilder(pager)
.redirectOutput(Redirect.INHERIT)
.redirectErrorStream(true)
.start();
PrintStream out = new PrintStream(process.getOutputStream());

setOutput(out);
boolean code = super.runLauncherAction();

out.flush();
out.close();
process.waitFor();

return code;
} catch (IOException | InterruptedException e) {
throw abort(e);
}
}

private int runRubyMain(Context.Builder contextBuilder, CommandLineOptions config) {
Expand Down

0 comments on commit b9e9375

Please sign in to comment.