File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -570,8 +570,7 @@ sqFileStdioHandlesInto(SQFile files[])
570570}
571571
572572sqInt sqStdioDescriptorIsATTY (void ) {
573- //There is always an TTY to write into for Unix and Mac
574- return 1 ;
573+ return isatty (fileno (stdin ));
575574}
576575
577576
Original file line number Diff line number Diff line change @@ -879,8 +879,10 @@ sqInt isStdioDescriptorATTY(void) {
879879 //In case of Windows Shell case
880880 int stdOutFd = _fileno (stdout );
881881 int res = _isatty (stdOutFd );
882- if (res != 0 ) return res > 0 ;
883- if (errno == EBADF ) return 0 ;
882+ if (res != 0 )
883+ return res > 0 ;
884+ if (errno == EBADF )
885+ return 0 ;
884886 //In case of Unix emulator, we parse the name of the pipe
885887 HANDLE h ;
886888 int size = sizeof (FILE_NAME_INFO ) + sizeof (WCHAR ) * MAX_PATH ;
@@ -894,11 +896,12 @@ sqInt isStdioDescriptorATTY(void) {
894896 DWORD dwBufferSize
895897 );
896898 static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL ;
897-
898- pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx )
899- GetProcAddress (GetModuleHandle (TEXT ("kernel32.dll" )), "GetFileInformationByHandleEx" );
900- if (pGetFileInformationByHandleEx == NULL ) return -2 ;
901-
899+ if (!pGetFileInformationByHandleEx ) {
900+ pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx )
901+ GetProcAddress (GetModuleHandle (TEXT ("kernel32.dll" )), "GetFileInformationByHandleEx" );
902+ if (!pGetFileInformationByHandleEx )
903+ return 0 ;
904+ }
902905 h = (HANDLE )_get_osfhandle (2 );
903906 if (h == INVALID_HANDLE_VALUE ) {
904907 return 0 ;
You can’t perform that action at this time.
0 commit comments