From 67e67c8ff9dba41877d575ae8c9fe348ee64494b Mon Sep 17 00:00:00 2001 From: snuyanzin Date: Thu, 23 Aug 2018 13:07:32 +0300 Subject: [PATCH] Use less for !manual command if not Windows --- src/main/java/sqlline/Commands.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/sqlline/Commands.java b/src/main/java/sqlline/Commands.java index 9b282ee3..106de08c 100644 --- a/src/main/java/sqlline/Commands.java +++ b/src/main/java/sqlline/Commands.java @@ -1465,6 +1465,26 @@ public void manual(String line, DispatchCallback callback) return; } + // Workaround for windows because of + // https://github.com/jline/jline3/issues/304 + if (System.getProperty("os.name").toLowerCase().contains("windows")) { + sillyLess(in); + } else { + try { + org.jline.builtins.Commands.less(sqlLine.getLineReader().getTerminal(), + in, sqlLine.getOutputStream(), sqlLine.getErrorStream(), + null, new String[]{}); + } catch (InterruptedException e) { + callback.setToFailure(); + sqlLine.error(e); + return; + } + } + + callback.setToSuccess(); + } + + private void sillyLess(InputStream in) throws IOException { BufferedReader breader = new BufferedReader(new InputStreamReader(in)); String man; @@ -1484,8 +1504,6 @@ public void manual(String line, DispatchCallback callback) } breader.close(); - - callback.setToSuccess(); } static Map asMap(Properties properties) {