mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-04 16:35:08 -05:00
* fix IO redirection issues when script is reading from STDIN
This commit is contained in:
parent
f1ad8c8cdf
commit
65e88be2b6
@ -10,6 +10,7 @@ import java.io.PrintStream;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Console} like class for when {@link System#console()} is not available in the current JVM
|
* A {@link Console} like class for when {@link System#console()} is not available in the current JVM
|
||||||
@ -18,6 +19,15 @@ import java.nio.charset.Charset;
|
|||||||
*/
|
*/
|
||||||
public class PseudoConsole {
|
public class PseudoConsole {
|
||||||
|
|
||||||
|
private static PseudoConsole STDIO;
|
||||||
|
|
||||||
|
public static synchronized PseudoConsole getSystemConsole() {
|
||||||
|
if (STDIO == null) {
|
||||||
|
STDIO = new PseudoConsole(System.in, System.out, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
return STDIO;
|
||||||
|
}
|
||||||
|
|
||||||
private final BufferedReader reader;
|
private final BufferedReader reader;
|
||||||
private final PrintWriter writer;
|
private final PrintWriter writer;
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@ -190,7 +189,7 @@ public abstract class ScriptShellBaseClass extends Script {
|
|||||||
|
|
||||||
// define global variable: console
|
// define global variable: console
|
||||||
public Object getConsole() {
|
public Object getConsole() {
|
||||||
return System.console() != null ? System.console() : new PseudoConsole(System.in, System.out, StandardCharsets.UTF_8);
|
return System.console() != null ? System.console() : PseudoConsole.getSystemConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getNow() {
|
public Date getNow() {
|
||||||
|
Loading…
Reference in New Issue
Block a user