From 25ed28fb5f4f03a480017da242e7dacf8afb81fc Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 9 May 2016 15:18:00 +0200 Subject: [PATCH] Rename isCygwin() to isXterm() Strictly speaking this method does not check for Cygwin (as it e.g. does not check to be on Windows) but only for XTerm (which in conjunction with being on Windows is a sign of running under Cygwin). Simplify the code a bit to get rid of the explicit null check long the way. --- .../src/main/java/org/fusesource/jansi/AnsiConsole.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java index 31b6b50c..3d16cfec 100644 --- a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java +++ b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java @@ -85,7 +85,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen } String os = System.getProperty("os.name"); - if (os.startsWith("Windows") && !isCygwin()) { + if (os.startsWith("Windows") && !isXterm()) { // On windows we know the console does not interpret ANSI codes.. try { @@ -107,7 +107,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen // If we can detect that stdout is not a tty.. then setup // to strip the ANSI sequences.. int rc = isatty(fileno); - if (!isCygwin() && !forceColored && rc == 0) { + if (!isXterm() && !forceColored && rc == 0) { return new AnsiOutputStream(stream); } @@ -129,9 +129,8 @@ public void close() throws IOException { }; } - private static boolean isCygwin() { - String term = System.getenv("TERM"); - return term != null && term.equals("xterm"); + private static boolean isXterm() { + return "xterm".equals(System.getenv("TERM")); } /**