Overview
| Artifact ID: | 9f146e56ffa385292e0d061c6d8b08911c653deee09d3beefebb17d9f75946c6 |
|---|---|
| Ticket: | aa9f3ef820b8c075c8fc663b6982704450e13912
Inconsistent behavior of "file exists" command |
| User & Date: | anonymous on 2025-11-12 12:43:04 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed to:
Working with serial ports the "file exists" command has weird behavior, inconsistent with both "file type" and "::open" command (it's not the known pitfall of missing prefix \\.\ for serial ports on Windows platform): --- a) The following returns 1 for EVERY serial port COM1 to COM9 (even if some of them do not exist): for {set i 1} {$i < 10} {incr i} { puts [file exists com$i] } Compared to this "file type" command works as expected and returns "characterSpecial" for serial ports available and raises errors for non-existing serial ports. --- b) Adding \\.\ prefix for Windows changes behavior (although behavior of "file type" does not change): for {set i 1} {$i < 10} {incr i} { puts [file exists [string cat {\\.\com} $i]] } This returns zero for all serial ports COM1 to COM9 even if they are available. However the following succeeds (for serial ports available): file type [string cat {\\.\com} 13] --- c) For COM ports > 10 "file exists" always return 0 even if they are available, e.g. puts [file exists {\\.\com13}] always returns zero. However the following succeeds (given that serial port is available): puts [file type {\\.\com13}] # -> characterSpecial set h [::open {\\.\com13} r] close $h --- The behavior seems inconsistent: Even if one defines that "file" commands work on disk files only why does "file exists" returns 1 for COM1 to COM9? And if one defines that "file" works on special devices like serial ports it should return 1 whenever "file type" returns "characterSpecial". Commands "file readable" and "file writable" show similar behavior btw. Platform is Windows 11 with Tcl 8.6.17 (other versions and platforms not tested yet). - foundin changed to: "8.6.17"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "37. File System"
- title changed to: "Inconsistent behavior of "file exists" command"
- type changed to: "Bug"