| Ticket UUID: | 1146047 | ||
| Title: | Unexpected [glob] result, when match is partly inaccessable | ||
| Type: | Bug | Created on: | 2005-02-22 08:16:35 |
| Submitter: | matzek | Assigned to: | dgp |
| Subsystem: | 37. File System | Severity: | |
| Priority: | 5 Medium | Last modified: | 2008-07-01 22:17:46 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | obsolete: 8.4.9 | ||
| Description: | ||||
[glob] is documented to behave like csh globbing, with
only two exceptions. The first (sorting) is not
relevant, the second says [glob] returns only existing
files. It might or might not be relevant, I can't tell...
The situation:
1) let me show how csh behaves on my Linux box and
therefore what I expected [glob] to return:
makr@pcmakr1:~> csh
/home/makr> ls -l / | grep '[rb]oot$'
drwxr-xr-x 4 root root 1024 2004-12-22
13:19 boot
drwx------ 17 root root 832 2005-01-24
08:33 root
/home/makr> echo /[rb]oot/*
/boot/System.map-2.4.20-4GB /boot/System.org
/boot/boot /boot/boot.0800 /boot/grub /boot/initrd
/boot/initrd.org /boot/initrd.shipped /boot/lost+found
/boot/map /boot/memtest.bin /boot/message
/boot/vmlinux.gz /boot/vmlinuz /boot/vmlinuz.autoconf.h
/boot/vmlinuz.config /boot/vmlinuz.org
/boot/vmlinuz.shipped /boot/vmlinuz.version.h
2) trying to use [glob] this way, however, gives me
either an error (a) or nothing (b):
a)
(makr) 53 % glob -- {/[rb]oot/*}
couldn't read directory "/root/": permission denied
b)
(makr) 54 % glob -nocomplain -- {/[rb]oot/*}
(makr) 55 %
Tcl version:
(makr) 52 % set tcl_patchLevel
8.4.9
To me the behavior in (a) is wrong as the documentation
makes me expect another result. The result of (b),
however, is also odd, when (a) is deemed as "works as
designed". After all, there might be cases, when it
might be good to know the pattern matches partly
inaccessable file system parts. On the other hand, if I
just want a list of accessable files this behavior
complicates life unneccessarily...
kind regards
-- Matthioas Kraft
| ||||
| User Comments: | ||||
vincentdarley added on 2005-02-22 17:48:13:
Logged In: YES user_id=32170 I'd agree that this is a bug. The most consistent approach for Tcl at present (IMHO) would be to leave (a) as is, and fix (b) to return the files in /boot/*. vincentdarley added on 2005-02-24 23:23:39:
Logged In: YES
user_id=32170
Here are a few observations from Windows, where I've been
testing. Here 'E:/System Volume Information' is inaccessible:
% glob {System Volume Information/*}
couldn't read directory "E:/System Volume Information/*":
permission denied
and 'E:/System Volume Informatiop' is ok:
% glob {System Volume Informatio[p]/*}
{System Volume Informatiop/test.txt}
So, on Windows I see this:
% glob {System Volume Informatio[np]/*}
{System Volume Informatiop/test.txt}
% glob {System Volume Informatio*/*}
{System Volume Informatiop/test.txt}
(which seems to contradict this bug report, hence suggesting
this bug is a unix-specific one).
An interesting point is this one:
% glob {System Volume Informatio[n]/*}
no files matched glob pattern "System Volume Informatio[n]/*"
so no 'permission denied' error message is given in this case...
So, I am interested what 'glob {/[r]oot/*}' gives on your
system...
matzek added on 2005-02-25 02:59:19:
Logged In: YES
user_id=330806
Well, seems on Windows it's doing what I want. Unfortunately
I need it on Unix only...
Anyway, here is what you asked for:
(matze) 51 % glob -- {/[r]oot/*}
couldn't read directory "/root/": permission denied
(matze) 52 % glob -nocomplain -- {/[r]oot/*}
(matze) 53 % glob -nocomplain -- {/[b]oot/*}
/boot/lost+found /boot/System.map-ide-2.4.26
/boot/config-ide-2.4.26 /boot/vmlinuz-ide-2.4.26
/boot/vmlinuz.old /boot/System.map /boot/vmlinuz
/boot/boot.0801 /boot/map /boot/boot.0800 /boot/System.org
/boot/vmlinuz.org /boot/grub /boot/System.old
/boot/boot.0200 /boot/memtest86.bin /boot/memtest86+.bin
/boot/boot /boot/diag1.img
(matze) 54 % glob -- {/[b]oot/*}
/boot/lost+found /boot/System.map-ide-2.4.26
/boot/config-ide-2.4.26 /boot/vmlinuz-ide-2.4.26
/boot/vmlinuz.old /boot/System.map /boot/vmlinuz
/boot/boot.0801 /boot/map /boot/boot.0800 /boot/System.org
/boot/vmlinuz.org /boot/grub /boot/System.old
/boot/boot.0200 /boot/memtest86.bin /boot/memtest86+.bin
/boot/boot /boot/diag1.img
I also went into the toplevel / directory and did this:
() 59 % glob -- {roo[t]/*}
couldn't read directory "root/": permission denied
... but to avail ...
kind regards
-- Matthias Kraft
vincentdarley added on 2005-02-26 22:09:53:
Logged In: YES
user_id=32170
The weird thing here is that I'm 99% sure that the effect
you're seeing is in the generic code in tclFilename.c, here:
/*
* We do the recursion ourselves. This makes implementing
* Tcl_FSMatchInDirectory for each filesystem much easier.
*/
*p = '\0';
TclNewObj(subdirsPtr);
result = Tcl_FSMatchInDirectory(interp, subdirsPtr, pathPtr,
pattern, &dirOnly);
*p = save;
if (result == TCL_OK) {
int subdirc, i;
Tcl_Obj **subdirv;
result = Tcl_ListObjGetElements(interp, subdirsPtr,
&subdirc, &subdirv);
for (i=0; result==TCL_OK && i<subdirc; i++) {
result = DoGlob(interp, matchesObj, separators, subdirv[i],
1, p+1, types);
}
}
TclDecrRefCount(subdirsPtr);
return result;
(that's cvs HEAD, tcl 8.5, although it works the same for me
with 8.4.7 on Windows).
So it's hard to understand... Can you try some debugging of
this?(i.e. set a breakpoint in the above code and see what's
going on).
matzek added on 2005-02-27 04:45:24:
Logged In: YES user_id=330806 Sure, I will, but it may take some time, propably earliest in 2 weeks... kind regards -- Matthias Kraft matzek added on 2008-07-01 22:17:46:
Logged In: YES user_id=330806 Originator: YES As briefly discussed in chat, can you examine and decide if it could be closed? The [glob -nocomplain] changed with 8.5, so this semantic couldn't be used anyway. As it seems to me. Thanks -- Matthias Kraft | ||||
