Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-10-29
21:27 • Closed ticket [475941ffff]: glob not returning filenames... plus 8 other cha... artifact: 2a75f188a7 user: dkf
20:54 • Ticket [475941ffff]: 4 changes artifact: abba87e214 user: petasis
19:50 • Ticket [475941ffff]: 4 changes artifact: d36de91d71 user: vincentdarley
16:22 • Add attachment GlobBug.tcl to ticket [475941ffff] artifact: e612299c79 user: petasis
16:22 • Ticket [475941ffff] glob not returning filenames... status still Open with 4... artifact: d72f978c87 user: petasis
09:22 • New ticket [475941ffff]. artifact: 65236bbbf3 user: petasis

glob not returning filenames...

Closed / Fixed475941ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-10-29 09:22:37
Tcl Version: 8.4a4 (CVS 25 October 2001)
OS: Unix (and perhaps Windows - untested)

Glob seems to fail to return filenames when the search is done
in a directory other than the current directory.
For example, the following script:

set CWD [pwd]

proc TestGlob {dir} {
  puts "Executing \"glob -nocomplain -types {f l r} $dir/*\"..."
  puts [glob -nocomplain -types {f l r} $dir/*]
  puts "Executing \"glob -nocomplain -types {f l r} -directory $dir *\"..."
  puts [glob -nocomplain -types {f l r} -directory $dir *]
  puts {}
}

TestGlob $CWD
cd ..
puts "**** Changing Directory to \"[pwd]\"..."
TestGlob $CWD

fails to return the file names in the second invocation
of the TestGlob procedure, after the current directory has been
changed...
petasisplain2001-10-29 16:22:39
File Added - 12573: GlobBug.tcl
vincentdarleyplain2001-10-29 19:50:22
Logged In: YES 
user_id=32170

I can see a perhaps-related bug in WinTcl which appeared 
around a month or so ago in cvs.  Adding these two tests to 
fileName.test:

test filename-11.25.1 {Tcl_GlobCmd} {
    list [catch {lsort [glob -type {d r} -dir $globname *]} 
msg] $msg
} [list 0 [lsort [list [file join $globname a1]\
  [file join $globname a2]\
  [file join $globname a3]]]]
test filename-11.25.2 {Tcl_GlobCmd} {
    list [catch {lsort [glob -type {d r w} -dir $globname 
*]} msg] $msg
} [list 0 [lsort [list [file join $globname a1]\
  [file join $globname a2]\
  [file join $globname a3]]]]

shows up that bug (put the above tests after filename-
11.25), but, looking at the code, it doesn't seem to be the 
same as your bug, which I can't reproduce (on Windows).

Can you tell me if your bug above is still shown if you 
remove the '-types' argument?
petasisplain2001-10-29 20:54:42
Logged In: YES 
user_id=92283

No, if you remove the -types argument it works as supposed
to work...
dkfplain2001-10-29 21:27:10
Logged In: YES 
user_id=79902

Hah!  Found the problem.  In the Unix TclpMatchInDirectory,
the access() syscall was being used to verify that types
matched. Which is good. But it was being called without the
pathname attached (unlike with stat() and lstat()) so it was
always checking against the files in the current directory
and not in the place where the matching was supposed to
happen. Which was bad (but is fixed now.)
Log in (anonymous is fine) to add a comment.

Attachments: