Skip to content
Tcl Source Code History Of Ticket aa9f3ef820
Login

History Of Ticket aa9f3ef820

Artifacts Associated With Ticket aa9f3ef820

  1. Ticket change [9f146e56ff] (rid 248108) by anonymous on 2025-11-12 12:43:04:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized 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).
      
    5. foundin initialized to: "8.6.17"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Important"
    11. status initialized to: "Open"
    12. submitter initialized to: "anonymous"
    13. subsystem initialized to: "37. File System"
    14. title initialized to: "Inconsistent behavior of "file exists" command"
    15. type initialized to: "Bug"