diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java index 31cd5d4..fdc2f50 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java +++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java @@ -229,6 +229,7 @@ public class Shell extends ShellOptions implements KeywordExecutable { private long lastUserActivity = System.nanoTime(); private boolean logErrorsToConsole = false; private boolean masking = false; + private PrintWriter writer = null; { // set the JLine output encoding to some reasonable default if it isn't already set @@ -252,6 +253,8 @@ public class Shell extends ShellOptions implements KeywordExecutable { public Shell(ConsoleReader reader) { super(); this.reader = reader; + this.writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty("jline.WindowsTerminal.output.encoding", +System.getProperty("file.encoding"))))); } /** @@ -264,6 +267,8 @@ public class Shell extends ShellOptions implements KeywordExecutable { public boolean config(String... args) throws IOException { if (this.reader == null) this.reader = new ConsoleReader(); + if (this.writer == null) + this.writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty("jline.WindowsTerminal.output.encoding", System.getProperty("file.encoding"))))); ShellOptionsJC options = new ShellOptionsJC(); JCommander jc = new JCommander(); @@ -726,10 +731,11 @@ public class Shell extends ShellOptions implements KeywordExecutable { } public void printInfo() throws IOException { - reader.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + writer.print("\n" + SHELL_DESCRIPTION + "\n" + "- \n" + "- version: " + Constants.VERSION + "\n" + "- instance name: " + connector.getInstance().getInstanceName() + "\n" + "- instance id: " + connector.getInstance().getInstanceID() + "\n" + "- \n" + "- type 'help' for a list of available commands\n" + "- \n"); + writer.flush(); reader.flush(); } @@ -761,7 +767,9 @@ public class Shell extends ShellOptions implements KeywordExecutable { } } sb.append("-\n"); - reader.print(sb.toString()); + writer.print(sb.toString()); + writer.flush(); + reader.flush(); } public String getDefaultPrompt() {