Skip to content

Commit

Permalink
diagnose isatty for both stdout and stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Sep 16, 2017
1 parent e35a57f commit 0484150
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions jansi/src/main/java/org/fusesource/jansi/AnsiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@ public static void main(String... args) throws IOException {

System.out.println();

int isattyValueReturned = isatty(CLibrary.STDOUT_FILENO);
if( isattyValueReturned == 0 ) {
System.out.println("stdout is *NOT* a TTY, 'isatty' has a value of " + isattyValueReturned);
} else {
System.out.println("stdout *IS* a TTY, 'isatty' has a value of " + isattyValueReturned);
}
diagnoseTty(false); // System.out
diagnoseTty(true); // System.err

AnsiConsole.systemInstall();
try {
Expand Down Expand Up @@ -130,6 +126,14 @@ private static String getJansiVersion() {
return ( p == null ) ? null : p.getImplementationVersion();
}

private static void diagnoseTty(boolean stderr) {
int fd = stderr ? CLibrary.STDERR_FILENO : CLibrary.STDOUT_FILENO;
int isatty = isatty(fd);

System.out.println("isatty(STD" + (stderr ? "ERR" : "OUT") + "_FILENO)= " + isatty + ", System."
+ (stderr ? "err" : "out") + " " + ((isatty == 0) ? "is *NOT*" : "is") + " a terminal");
}

private static String getPomPropertiesVersion(String path) throws IOException {
InputStream in = AnsiMain.class.getResourceAsStream("/META-INF/maven/" + path + "/pom.properties");
if (in == null) {
Expand Down

0 comments on commit 0484150

Please sign in to comment.