Skip to content

Commit

Permalink
on MSYSTEM=MINGW, only BASH is natively ANSI aware, not Git CMD #119
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Apr 14, 2018
1 parent 48b0be5 commit 73c621f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
* @since 1.0
* @see #wrapPrintStream(PrintStream, int)
* @see #wrapPrintStream(PrintStream, int) wrapPrintStream(PrintStream, int) for more details on ANSI mode selection
* @see #systemInstall()
*/
public class AnsiConsole {
Expand All @@ -48,9 +48,10 @@ public class AnsiConsole {
&& System.getenv("PWD").startsWith("/")
&& !"cygwin".equals(System.getenv("TERM"));

static final boolean IS_MINGW = IS_WINDOWS
static final boolean IS_MINGW_BASH = IS_WINDOWS
&& System.getenv("MSYSTEM") != null
&& System.getenv("MSYSTEM").startsWith("MINGW");
&& System.getenv("MSYSTEM").startsWith("MINGW")
&& System.getenv("BASH") != null;

private static JansiOutputType jansiOutputType;
static final JansiOutputType JANSI_STDOUT_TYPE;
Expand Down Expand Up @@ -118,7 +119,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen
return new AnsiOutputStream(stream);
}

if (IS_WINDOWS && !IS_CYGWIN && !IS_MINGW) {
if (IS_WINDOWS && !IS_CYGWIN && !IS_MINGW_BASH) {

// On windows we know the console does not interpret ANSI codes..
try {
Expand Down Expand Up @@ -196,7 +197,7 @@ public static PrintStream wrapPrintStream(final PrintStream ps, int fileno) {
return new AnsiPrintStream(ps);
}

if (IS_WINDOWS && !IS_CYGWIN && !IS_MINGW) {
if (IS_WINDOWS && !IS_CYGWIN && !IS_MINGW_BASH) {

// On windows we know the console does not interpret ANSI codes..
try {
Expand Down Expand Up @@ -271,6 +272,7 @@ public static PrintStream err() {
/**
* Install <code>AnsiConsole.out</code> to <code>System.out</code> and
* <code>AnsiConsole.err</code> to <code>System.err</code>.
* @see #systemUninstall()
*/
synchronized static public void systemInstall() {
installed++;
Expand All @@ -282,7 +284,7 @@ synchronized static public void systemInstall() {

/**
* undo a previous {@link #systemInstall()}. If {@link #systemInstall()} was called
* multiple times, it {@link #systemUninstall()} must call the same number of times before
* multiple times, {@link #systemUninstall()} must be called the same number of times before
* it is actually uninstalled.
*/
synchronized public static void systemUninstall() {
Expand Down
2 changes: 1 addition & 1 deletion jansi/src/main/java/org/fusesource/jansi/AnsiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void main(String... args) throws IOException {
System.out.println("IS_WINDOWS: " + AnsiConsole.IS_WINDOWS);
if (AnsiConsole.IS_WINDOWS) {
System.out.println("IS_CYGWIN: " + AnsiConsole.IS_CYGWIN);
System.out.println("IS_MINGW: " + AnsiConsole.IS_MINGW);
System.out.println("IS_MINGW_BASH: " + AnsiConsole.IS_MINGW_BASH);
}

System.out.println();
Expand Down

0 comments on commit 73c621f

Please sign in to comment.