Tcl Source Code

View Ticket
Login
Ticket UUID: 475941
Title: glob not returning filenames...
Type: Bug Version: obsolete: 8.4a4
Submitter: petasis Created on: 2001-10-29 09:22:37
Subsystem: 37. File System Assigned To: dkf
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-10-29 21:27:10
Resolution: Fixed Closed By: dkf
    Closed on: 2001-10-29 14:27:10
Description:
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...
User Comments: dkf added on 2001-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.)

petasis added on 2001-10-29 20:54:42:
Logged In: YES 
user_id=92283

No, if you remove the -types argument it works as supposed
to work...

vincentdarley added on 2001-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?

petasis added on 2001-10-29 16:22:39:

File Added - 12573: GlobBug.tcl

Attachments: