Skip to content

Commit 0d398a5

Browse files
committed
Check isatty() separately for stdout and stderr
1 parent c3b76bc commit 0d398a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.fusesource.jansi;
1919

20+
import static org.fusesource.jansi.internal.CLibrary.STDERR_FILENO;
2021
import static org.fusesource.jansi.internal.CLibrary.STDOUT_FILENO;
2122
import static org.fusesource.jansi.internal.CLibrary.isatty;
2223

@@ -37,11 +38,15 @@ public class AnsiConsole {
3738
public static final PrintStream out = new PrintStream(wrapOutputStream(system_out));
3839

3940
public static final PrintStream system_err = System.err;
40-
public static final PrintStream err = new PrintStream(wrapOutputStream(system_err));
41+
public static final PrintStream err = new PrintStream(wrapOutputStream(system_err, STDERR_FILENO));
4142

4243
private static int installed;
4344

4445
public static OutputStream wrapOutputStream(final OutputStream stream) {
46+
return wrapOutputStream(stream, STDOUT_FILENO);
47+
}
48+
49+
public static OutputStream wrapOutputStream(final OutputStream stream, int fileno) {
4550

4651
// If the jansi.passthrough property is set, then don't interpret
4752
// any of the ansi sequences.
@@ -77,7 +82,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream) {
7782
boolean forceColored = Boolean.getBoolean("jansi.force");
7883
// If we can detect that stdout is not a tty.. then setup
7984
// to strip the ANSI sequences..
80-
int rc = isatty(STDOUT_FILENO);
85+
int rc = isatty(fileno);
8186
if( !forceColored && rc==0 ) {
8287
return new AnsiOutputStream(stream);
8388
}

0 commit comments

Comments
 (0)