Skip to content

Commit

Permalink
Do not use System.in directly
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Sep 5, 2017
1 parent 9383ba1 commit 60300ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions builtins/src/main/java/org/jline/builtins/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.jline.builtins;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Path;
import java.time.LocalTime;
Expand Down Expand Up @@ -105,7 +106,7 @@ public static void nano(Terminal terminal, PrintStream out, PrintStream err,
edit.run();
}

public static void less(Terminal terminal, PrintStream out, PrintStream err,
public static void less(Terminal terminal, InputStream in, PrintStream out, PrintStream err,
Path currentDir,
String[] argv) throws IOException, InterruptedException {
final String[] usage = {
Expand Down Expand Up @@ -148,7 +149,7 @@ public static void less(Terminal terminal, PrintStream out, PrintStream err,
}
for (String arg : opt.args()) {
if ("-".equals(arg)) {
sources.add(new StdInSource());
sources.add(new StdInSource(in));
} else {
sources.add(new URLSource(currentDir.resolve(arg).toUri().toURL(), arg));
}
Expand Down
6 changes: 5 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ public InputStream read() throws IOException {
class StdInSource extends InputStreamSource {

public StdInSource() {
super(System.in, false, null);
this(System.in);
}

public StdInSource(InputStream in) {
super(in, false, null);
}

}
Expand Down

0 comments on commit 60300ec

Please sign in to comment.