Artifacts Associated With Ticket a0db647efa
Ticket change [92515ecf5d] (rid 153527) by anonymous on 2017-05-03 18:15:00:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Mintty is the default console for MSYS2. I don't know what MinGW or Cygwin uses. In generic/tclMain.c tcl_interactive is set based on the result of isatty(0). On windows with mintty this is not sufficient. Thus, if one starts tclsh/wish while using mintty, there is no "% " prompt. 1. From https://msdn.microsoft.com/en-us/library/ms235388.aspx the recommendation is to use _isatty(). Also one should use _fileno(stdout) rather than hard-coding a "0". 2. From a discussion of comp.lang.tcl about whether Tcl could determine if a file descriptor (stdout) was really a terminal, the conclusion I came to was that it was not possible (at least on windows). 3. I encountered this issue also with fossil -- it did not read a password typed interactively when I used mintty. As I know next to nothing about windows api's, I will quote an email from the fossil.users list in response to my naive patch to fossil. The email points to several resources that might address a solution. Date: Wed, 3 May 2017 11:26:42 +0200 To: [email protected] Subject: Re: [fossil-users] Suggested patch for src/user.c (password prompt) 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.
- foundin initialized to: "8.6.6"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- private_contact initialized to: "b8731723488b9adb1562242d803fdc609ed3d701"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "07. Variables"
- title initialized to:
tcl_interactive wrong on windows when using mintty (MSYS2, win7x64)
- type initialized to: "Bug"
Ticket change [5a9ae55efc] (rid 153529) by anonymous on 2017-05-03 22:16:24:
- icomment:
After reviewing my notes and thinking about this, I don't know why I submitted it. It is not possible to determine if the terminal app is mintty (or the equivalent for Cyginw/MinGW) because they use a specific named pipe for emulating input/output. Without knowing the specific name, all that can be determined is that stdin/stdout is not a console. I'm not sure if the info at http://archives.miloush.net/michkap/archive/2008/03/18/8306597.html is of interest for tclsh/wish. The referenced code first determines if the stdout handle is a character device before it calls GetConsoleMode(). After doing some testing for last couple of hours, it appears to me that _isatty(_fileno(stdout)) is sufficient. Sorry I wasted your time.
- login: "anonymous"
- mimetype: "text/plain"
- icomment: