Skip to content

Commit

Permalink
Another attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 2, 2023
1 parent a47cf93 commit f044f9c
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/main/native/jansi_isatty.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,25 @@ JNIEXPORT jint JNICALL CLibrary_NATIVE(isatty)
else {

name = nameinfo->Name.Buffer;
name[nameinfo->Name.Length / 2] = 0;

//fprintf( stderr, "Standard stream %d: pipe name: %S\n", arg0, name);

/*
* Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
* or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX')
*/
if ((wcsstr(name, L"msys-") || wcsstr(name, L"cygwin-")) && wcsstr(name, L"-pty")) {
rc = 1;
} else {
// This is definitely not a tty
rc = 0;
if (name == NULL) {
rc = 0;
}
else {
name[nameinfo->Name.Length / 2] = 0;

//fprintf( stderr, "Standard stream %d: pipe name: %S\n", arg0, name);

/*
* Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
* or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX')
*/
if ((wcsstr(name, L"msys-") || wcsstr(name, L"cygwin-")) && wcsstr(name, L"-pty")) {
rc = 1;
} else {
// This is definitely not a tty
rc = 0;
}
}
}
}
}
Expand Down

0 comments on commit f044f9c

Please sign in to comment.