Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 67b317145ec6f3ebcd6204e2b67c1490ec4fc332e814dbade7011c346c159273
Ticket: e5c21e566ff31a51f85bf12e0b5031993a3c4b4a
inconsistent handling of glob -nocomplain
User & Date: sebres on 2025-08-13 17:02:18
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    It looks that on certain circumstances glob -nocomplain may complain about "no such file or directory". Still worse for Tcl 9, because since TIP#637 -glob always works as "nocomplain" now.
    
    Normally, following code would return an empty list if the directory doesn't exist:
    <code><pre>
    % glob -nocomplain -directory {/path/that/does/not/exist} *.ext
    ~empty~
    </pre></code>
    
    However sometimes (depending on file-system/platform/whatever) it may fail... for instance this happens by some of my customer on some SMB-share on Windows:
    <code><pre>
    % glob -nocomplain -directory {//server/smb-share/no-such-path} *.ext
    couldn't read directory "//server/smb-share/no-such-path/*.ext": no such file or directory
    </pre></code>
    
    I cannot reproduce it directly in this constellation on my boxes, but I guess I found it in source code, and was able to reproduce another similar "inconsistence" (e. g. if there is no access to directory):
    <code><pre>
    % glob -nocomplain -directory {/path-without-permissions} *.ext
    couldn't read directory "/path-without-permissions/*.ext": permission denied
    % glob -nocomplain -directory {/path-without-permissions/.} *.ext
    ~empty~
    % glob -nocomplain -directory {/path-without-permissions/other} *.ext
    ~empty~
    </pre></code>
    The reason seems to be that neither DoGlob nor Tcl_FSMatchInDirectory know 
    TCL_GLOBMODE_NO_COMPLAIN flag, or rather trying to distinguish the error codes internally,  so by the error they'd simply set it to the interpreter and return with TCL_ERROR.
    
    I'm pretty sure that from point of view of not complaining glob, both codes, ENOENT and EACCES, shall be considered as no hits, and glob has to return empty list without to complain the error, no matter how deep exactly it was caused.
    
  5. foundin changed to: "any"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "50e9528765c18296566374b3fde2df942c394efd"
  10. resolution changed to: "None"
  11. severity changed to: "Severe"
  12. status changed to: "Open"
  13. submitter changed to: "sebres"
  14. subsystem changed to: "37. File System"
  15. title changed to: "inconsistent handling of glob -nocomplain"
  16. type changed to: "Bug"