Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9ffd549a8370742adb7aa989c6cf40f41f367bdb9eebc76a8450cf4735b93d1f
Ticket: e860418c2d20c7bf93f751b9d56dd2644440a45a
glob -dir $dir -tail returns name with leading / if $dir ends in a /
User & Date: apnadkarni on 2026-05-21 06:58:31
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-markdown"
  4. comment changed to:
    Originally reported by @JulianNoble in the discussion in unrelated issue [596936dd2d](https://core.tcl-lang.org/tcl/tktview/596936dd)
    
    ```
    When you do a glob -dir $dir -tail on a dir ending in a slash - it can return /name instead of just name 
    
    Then the file join fails to work as it takes the name as an absolute path and doesn't add the dir.
    
     #with trailing slash in path
     % set path {C:\Program Files\PowerShell\7}
     C:\Program Files\PowerShell\7
     % tcl::unsupported::representation $path
     value is a pure string with a refcount of 4, object pointer at 0x1ea036f3270, string representation "C:\Program Fi..."
     % append path \\
     C:\Program Files\PowerShell\7\
     % tcl::unsupported::representation $path
    value is a utf32string with a refcount of 2, object pointer at 0x1ea036ef2e0, internal representation 0x1ea038c70b0:0x0, string representation "C:\Program Fi..."
     % glob -dir $path -tail pwsh.exe
     /pwsh.exe
    
    
     
     #without trailing slash 
     % set path {C:\Program Files\PowerShell\7}
     C:\Program Files\PowerShell\7
     % tcl::unsupported::representation $path
    value is a pure string with a refcount of 5, object pointer at 0x1ea036f3270, string representation "C:\Program Fi..."
     % glob -dir $path -tail pwsh.exe
     pwsh.exe
    
    
    Whether or not a trailing slash should strictly exist at the end of a path - I believe it to be fairly common on windows (some installers do it) and it should work.
    
    Tcl8.5 on the other hand does it correctly:
    
    % glob -dir "c:\\" -tail windows-version.txt
    windows-version.txt
    
    versus testing in 8.6, 8.7, 9.0
    % glob -dir "c:\\" -tail windows-version.txt
    /windows-version.txt
    ```
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "apnadkarni"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "9546e9877f1a8899e25a89082561ee694e7fb402"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "apnadkarni"
  14. subsystem changed to: "- New Builtin Commands"
  15. title changed to:
    glob -dir $dir -tail returns name with leading / if $dir ends in a /
    
  16. type changed to: "Bug"