| Ticket UUID: | 223313 | |||
| Title: | many uses of 'glob [file join $dir $pat]' in Tcl and Tk | |||
| Type: | Bug | Version: | ||
| Submitter: | vincentdarley | Created on: | 2000-11-24 09:38:24 | |
| Subsystem: | 76. Widget Tour | Assigned To: | dkf | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2001-08-10 15:35:08 | |
| Resolution: | Fixed | Closed By: | dkf | |
| Closed on: | 2001-08-10 08:35:08 | |||
| Description: |
Almost all uses of 'glob [file join $dir $pat]' are bugs. (Does procheck report an error for these statements?). If the directory '$dir' contains glob sensitive characters, the command will either fail or return bad results.
The correct version is:
glob -dir $dir $pat
or for 'glob [file join $dir * $pat]' we need:
glob -dir $dir -join * $pat
(or variants on that theme). A search through my 'lib' hierarchy shows the following instances, all of which are bugs. These are in Tcl's library, Tk's library and in some iwidgets code.
Vince.
C:/Program Files/Tcl/lib/iwidgets3.0.0/demos/catalog
"catalog"; Line 392:
foreach file [lsort [glob [file join ${iwidgets::library} demos *]]] {
C:/Program Files/Tcl/lib/iwidgets3.0.0/scripts/extfileselectionbox.itk
"extfileselectionbox.itk"; Line 791:
set files [lsort [glob -nocomplain [file join $_pwd $mask]]]
C:/Program Files/Tcl/lib/iwidgets3.0.0/scripts/fileselectionbox.itk
"fileselectionbox.itk"; Line 749:
set files [lsort [glob -nocomplain [file join $_pwd $mask]]]
C:/Program Files/Tcl/lib/tcl8.4/package.tcl
"package.tcl"; Line 440:
foreach x [glob -nocomplain [file join $dir *.shlb]] {
C:/Program Files/Tcl/lib/tcl8.4/package.tcl
"package.tcl"; Line 480:
foreach file [glob -nocomplain [file join $dir * pkgIndex.tcl]] {
C:/Program Files/Tcl/lib/tcl8.4/package.tcl
"package.tcl"; Line 512:
foreach x [glob -nocomplain [file join $dir *]] {
C:/Program Files/Tcl/lib/tcl8.4/safe.tcl
"safe.tcl"; Line 499:
foreach sub [glob -nocomplain -- [file join $dir *]] {
C:/Program Files/Tcl/lib/tcl8.4/tcltest1.0/tcltest.tcl
"tcltest.tcl"; Line 1579:
[glob -nocomplain [file join $directory $match]]]
C:/Program Files/Tcl/lib/tcl8.4/tcltest1.0/tcltest.tcl
"tcltest.tcl"; Line 1585:
[glob -nocomplain [file join $directory $skip]]]
C:/Program Files/Tcl/lib/tk8.4/demos/image2.tcl
"image2.tcl"; Line 23:
foreach i [lsort [glob [file join $dirName *]]] {
| |||
| User Comments: |
dkf added on 2001-08-10 15:35:07:
Logged In: YES user_id=79902 OK, sorted except for itk. But that's a separate project (currently) and so None Of My Business. :^) vincentdarley added on 2001-08-09 00:55:36:
File Added - 9381: globtk.patch
Logged In: YES
user_id=32170
Attached a patch to fix this problem in Tk, then it will
only be a problem in iwidgets.
diff -U3 -r1.2 image2.tcl
--- image2.tcl1998/09/14 18:23:291.2
+++ image2.tcl2001/08/08 17:53:48
@@ -20,7 +20,7 @@
global dirName
$w.f.list delete 0 end
- foreach i [lsort [glob [file join $dirName *]]] {
+ foreach i [lsort [glob -directory $dirName *]] {
$w.f.list insert end [file tail $i]
}
}
dkf added on 2000-11-24 21:17:46: Fixed in Tcl. Now a Tk bug only... | |||
Attachments:
- globtk.patch [download] added by vincentdarley on 2001-08-09 00:55:36. [details]
