Skip to content
Tcl Source Code Artifact [9f146e56ff]
Login

Artifact [9f146e56ff]

Artifact 9f146e56ffa385292e0d061c6d8b08911c653deee09d3beefebb17d9f75946c6:

Ticket change [9f146e56ff] - New ticket [aa9f3ef820b8c075|aa9f3ef820] <i>Inconsistent behavior of &quot;file exists&quot; command</i>. by anonymous on 2025-11-12 12:43:04.
D 2025-11-12T12:43:04.690
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-plain
J comment Working\swith\sserial\sports\sthe\s"file\sexists"\scommand\shas\sweird\sbehavior,\sinconsistent\swith\sboth\s"file\stype"\sand\s"::open"\scommand\s(it's\snot\sthe\sknown\spitfall\sof\smissing\sprefix\s\\\\.\\\sfor\sserial\sports\son\sWindows\splatform):\r\n\r\n---\r\na)\sThe\sfollowing\sreturns\s1\sfor\sEVERY\sserial\sport\sCOM1\sto\sCOM9\s(even\sif\ssome\sof\sthem\sdo\snot\sexist):\r\n\r\n\s\s\s\sfor\s{set\si\s1}\s{$i\s<\s10}\s{incr\si}\s{\r\n\s\s\s\s\s\s\s\sputs\s[file\sexists\scom$i]\r\n\s\s\s\s}\r\n\r\nCompared\sto\sthis\s"file\stype"\scommand\sworks\sas\sexpected\sand\sreturns\s"characterSpecial"\sfor\sserial\sports\savailable\sand\sraises\serrors\sfor\snon-existing\sserial\sports.\r\n\r\n---\r\nb)\sAdding\s\\\\.\\\sprefix\sfor\sWindows\schanges\sbehavior\s(although\sbehavior\sof\s"file\stype"\sdoes\snot\schange):\r\n\r\n\s\s\s\sfor\s{set\si\s1}\s{$i\s<\s10}\s{incr\si}\s{\r\n\s\s\s\s\s\s\s\sputs\s[file\sexists\s[string\scat\s{\\\\.\\com}\s$i]]\r\n\s\s\s\s}\r\n\r\nThis\sreturns\szero\sfor\sall\sserial\sports\sCOM1\sto\sCOM9\seven\sif\sthey\sare\savailable.\sHowever\sthe\sfollowing\ssucceeds\s(for\sserial\sports\savailable):\r\n\r\n\s\s\s\sfile\stype\s[string\scat\s{\\\\.\\com}\s13]\r\n\r\n---\r\nc)\sFor\sCOM\sports\s>\s10\s"file\sexists"\salways\sreturn\s0\seven\sif\sthey\sare\savailable,\se.g.\r\n\r\n\s\s\s\sputs\s[file\sexists\s{\\\\.\\com13}]\r\n\r\nalways\sreturns\szero.\sHowever\sthe\sfollowing\ssucceeds\s(given\sthat\sserial\sport\sis\savailable):\r\n\r\n\s\s\s\sputs\s[file\stype\s{\\\\.\\com13}]\r\n\s\s\s\s#\s->\scharacterSpecial\r\n\r\n\s\s\s\sset\sh\s[::open\s{\\\\.\\com13}\sr]\r\n\s\s\s\sclose\s$h\r\n\r\n---\r\n\r\nThe\sbehavior\sseems\sinconsistent:\sEven\sif\sone\sdefines\sthat\s"file"\scommands\swork\son\sdisk\sfiles\sonly\swhy\sdoes\s"file\sexists"\sreturns\s1\sfor\sCOM1\sto\sCOM9?\sAnd\sif\sone\sdefines\sthat\s"file"\sworks\son\sspecial\sdevices\slike\sserial\sports\sit\sshould\sreturn\s1\swhenever\s"file\stype"\sreturns\s"characterSpecial".\r\n\r\nCommands\s"file\sreadable"\sand\s"file\swritable"\sshow\ssimilar\sbehavior\sbtw.\r\n\r\nPlatform\sis\sWindows\s11\swith\sTcl\s8.6.17\s(other\sversions\sand\splatforms\snot\stested\syet).
J foundin 8.6.17
J is_private 0
J login anonymous
J priority 5\sMedium
J resolution None
J severity Important
J status Open
J submitter anonymous
J subsystem 37.\sFile\sSystem
J title Inconsistent\sbehavior\sof\s"file\sexists"\scommand
J type Bug
K aa9f3ef820b8c075c8fc663b6982704450e13912
U anonymous
Z 8dd90037c9bd442693ccbf0af854bc9a