8135151: jjs should work in cygwin environment
authorsundar
Mon, 07 Sep 2015 20:07:03 +0530
changeset 32525 3244ec62a5cb
parent 32524 bd52a0be10a5
child 32526 0dab24cf1c3c
8135151: jjs should work in cygwin environment Reviewed-by: attila, hannesw
nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java	Mon Sep 07 11:11:41 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java	Mon Sep 07 20:07:03 2015 +0530
@@ -49,9 +49,9 @@
 
     Console(final InputStream cmdin, final PrintStream cmdout, final File historyFile,
             final Completer completer) throws IOException {
+        TerminalFactory.registerFlavor(Flavor.WINDOWS, isCygwin()? JJSUnixTerminal::new : JJSWindowsTerminal::new);
+        TerminalFactory.registerFlavor(Flavor.UNIX, JJSUnixTerminal::new);
         in = new ConsoleReader(cmdin, cmdout);
-        TerminalFactory.registerFlavor(Flavor.WINDOWS, JJSWindowsTerminal :: new);
-        TerminalFactory.registerFlavor(Flavor.UNIX, JJSUnixTerminal :: new);
         in.setExpandEvents(false);
         in.setHandleUserInterrupt(true);
         in.setBellEnabled(true);
@@ -134,4 +134,8 @@
             setAnsiSupported(false);
         }
     }
+
+    private static boolean isCygwin() {
+        return System.getenv("SHELL") != null;
+    }
 }