Merge 9.0 Fix [e860418c] Windows: glob -dir $dir -tail returns name with leading /

This commit is contained in:
apnadkarni
2026-05-25 10:59:43 +00:00
2 changed files with 24 additions and 2 deletions
+2 -2
View File
@@ -909,8 +909,8 @@ TclpNativeJoinPath(
* Check to see if we need to append a separator.
*/
if ((length > 0) &&
(start[length-1] != '/') && (start[length-1] != ':')) {
if ((length > 0) && (start[length-1] != '/') &&
(start[length-1] != '\\') && (start[length-1] != ':')) {
Tcl_AppendToObj(prefix, "/", 1);
(void)TclGetStringFromObj(prefix, &length);
}
+22
View File
@@ -1492,6 +1492,28 @@ test filename-16.17 {windows specific globbing} -constraints {win} -body {
list [glob -nocomplain -tails -dir C:/ *] \
[glob -nocomplain -tails -dir C: *]
} -match compareWords -result equal
test filename-16.18.1 {
Bug e860418c2d - glob -dir $dir -tail has leading / if $dir ends in a \
} -constraints win -setup {
lassign [file split $::env(WINDIR)] drv fn
set drv [file nativename $drv]
} -body {
string equal -nocase \
[lindex [glob -dir ${drv} -tails $fn] 0] \
[file tail $::env(WINDIR)]
} -cleanup {
unset -nocomplain drv fn
} -result 1
test filename-16.18.2 {
Bug e860418c2d - glob -dir $dir has extra separator if $dir ends in \
} -constraints win -setup {
lassign [file split $::env(WINDIR)] drv fn
set drv [file nativename $drv]
} -body {
string equal [lindex [glob -dir ${drv} $fn] 0] $::env(WINDIR)
} -cleanup {
unset -nocomplain drv fn
} -result 1
# Put the working directory back now that we're done with globbing in C:/
if {[testConstraint win]} {