<i>tcl_interactive wrong on windows when using mintty (MSYS2, win7x64)</i>.
by
.
D 2017-05-03T18:15:00.865
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment Mintty\sis\sthe\sdefault\sconsole\sfor\sMSYS2.\sI\sdon't\sknow\swhat\sMinGW\sor\sCygwin\suses.\r\n\r\nIn\sgeneric/tclMain.c\stcl_interactive\sis\sset\sbased\son\sthe\sresult\sof\sisatty(0).\sOn\swindows\swith\smintty\sthis\sis\snot\ssufficient.\sThus,\sif\sone\sstarts\stclsh/wish\swhile\susing\smintty,\sthere\sis\sno\s"%\s"\sprompt.\r\n\r\n1.\sFrom\shttps://msdn.microsoft.com/en-us/library/ms235388.aspx\sthe\srecommendation\sis\sto\suse\s_isatty().\sAlso\sone\sshould\suse\s_fileno(stdout)\srather\sthan\shard-coding\sa\s"0".\r\n\r\n2.\sFrom\sa\sdiscussion\sof\scomp.lang.tcl\sabout\swhether\sTcl\scould\sdetermine\sif\sa\sfile\sdescriptor\s(stdout)\swas\sreally\sa\sterminal,\sthe\sconclusion\sI\scame\sto\swas\sthat\sit\swas\snot\spossible\s(at\sleast\son\swindows).\r\n\r\n3.\sI\sencountered\sthis\sissue\salso\swith\sfossil\s--\sit\sdid\snot\sread\sa\spassword\styped\sinteractively\swhen\sI\sused\smintty.\r\n\r\nAs\sI\sknow\snext\sto\snothing\sabout\swindows\sapi's,\sI\swill\squote\san\semail\sfrom\sthe\sfossil.users\slist\sin\sresponse\sto\smy\snaive\spatch\sto\sfossil.\sThe\semail\spoints\sto\sseveral\sresources\sthat\smight\saddress\sa\ssolution.\r\n\r\nDate:\sWed,\s3\sMay\s2017\s11:26:42\s+0200\r\nTo:\[email protected]\r\nSubject:\sRe:\s[fossil-users]\sSuggested\spatch\sfor\ssrc/user.c\s(password\sprompt)\r\n\r\nJust\sbecause\sI\shave\sdone\ssome\sresearch\sabout\sthis\stopic\srecently,\sand\sfind\sit\sinteresting,\splease\sallow\sme\sto\sask\swhy\syou\scan\smake\sany\sassumptions\sregarding\sSTDIN,\safter\sonly\stesting\sSTDERR?\sCouldn't\seach\sof\sthe\sstandard\shandles\sbe\sredirected\sindividually,\sas\sin\s"COMMAND\s<input.txt\s1>nul\s2>errors.log"?\r\n\r\nTo\sdistinguish\sconsole\shandles\sfrom\sfiles,\spipes\sand\sother\sredirected\sdevices\son\sWindows,\sMSDN\srecommends\susing\sGetConsoleMode(),\sas\sfor\sexample\smentioned\sin\sthe\sdocumentation\sfor\sWriteConsole():\r\n\r\nhttps://msdn.microsoft.com/en-us/library/windows/desktop/ms687401.aspx\r\n\r\n"...\sdetermine\swhether\sthe\soutput\shandle\sis\sa\sconsole\shandle\s(one\smethod\sis\sto\scall\sthe\sGetConsoleMode\sfunction\sand\scheck\swhether\sit\ssucceeds)\s..."\r\n\r\nA\smore\sdetailed\stest\sfrom\sMichael\sKaplan,\ssimilar\sto\searlier\sversions\sof\sMSVCRT\s(current\sUCRT\sseems\sto\srely\son\sa\scombined\stest\sof\sisatty(),\sGetFileType()\sand\sGetConsoleMode(),\snow):\r\n\r\nhttp://archives.miloush.net/michkap/archive/2008/03/18/8306597.html\r\n\r\nA\scomment\sby\sRaymond\sChen\swhy\sGetFileType()\salone\s(as\sused\sby\ssome\sisatty()\sCRT\simplementations)\sis\snot\ssufficient\sto\sdetect\sa\sconsole\shandle:\r\n\r\nhttps://blogs.msdn.microsoft.com/junfeng/2005/07/08/how-do-i-know-if-console-handle-is-redirected/\r\n\r\nMy\sinvestigations\swere\sabout\soutput\shandles,\sbut\sGetConsoleMode()\scan\salso\sbe\sused\swith\sinput\shandles.
J foundin 8.6.6
J is_private 0
J login anonymous
J priority 5\sMedium
J private_contact b8731723488b9adb1562242d803fdc609ed3d701
J resolution None
J severity Minor
J status Open
J submitter anonymous
J subsystem 07.\sVariables
J title tcl_interactive\swrong\son\swindows\swhen\susing\smintty\s(MSYS2,\swin7x64)
J type Bug
K a0db647efa38b81784feba65ff6f3dfd7fa23eb1
U anonymous
Z 09a8368b63ddbd89887c96ed0162d9f0