Just because I have done some research about this topic recently, and
find it interesting, please allow me to ask why you can make any
assumptions regarding STDIN, after only testing STDERR? Couldn't each
of the standard handles be redirected individually, as in "COMMAND
<input.txt 1>nul 2>errors.log"?

To distinguish console handles from files, pipes and other redirected
devices on Windows, MSDN recommends using GetConsoleMode(), as for
example mentioned in the documentation for WriteConsole():

https://msdn.microsoft.com/en-us/library/windows/desktop/ms687401.aspx

"... determine whether the output handle is a console handle (one
method is to call the GetConsoleMode function and check whether it
succeeds) ..."

A more detailed test from Michael Kaplan, similar to earlier versions
of MSVCRT (current UCRT seems to rely on a combined test of isatty(),
GetFileType() and GetConsoleMode(), now):

http://archives.miloush.net/michkap/archive/2008/03/18/8306597.html

A comment by Raymond Chen why GetFileType() alone (as used by some
isatty() CRT implementations) is not sufficient to detect a console
handle:

https://blogs.msdn.microsoft.com/junfeng/2005/07/08/how-do-i-know-if-console-handle-is-redirected/

My investigations were about output handles, but GetConsoleMode() can
also be used with input handles.

--Florian
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to