Overview
| Artifact ID: | 2cf6348f99db328b1bccc47d8290294e275ef896 |
|---|---|
| Ticket: | 2710920fffffffffffffffffffffffffffffffff
[file tail] gives wrong result |
| User & Date: | dgp on 2009-03-28 01:07:00 |
Changes
- icomment:
The mystery as to why the behavior is different whether or not the demo script is [source]d by relative or absolute name is complex, but explainable. When the file name is absolute, there's never any need to ask what the [pwd] value is in order to open and read that file. In this simple test script, it happens that nothing else needed to know that value either, so the value of [pwd] has never been determined. In the innermost part of the [glob] operation, we need to query the actual filesystem to determine what files exist. The routine TclpMatchInDirectory() in tclUnixFile.c does this, and it must construct the "native" name of the file to do so. It calls the routine Tcl_FSGetNativePath() to get that native name. This works its way back to the routine TclNativeCreateNativeRep() also in tclUnixFile.c. TNCNR has two branches depending on whether or not the [pwd] value is known to be in the native filesystem. In the case where we've never had reason to determine [pwd] up to that point, [pwd] is not known to be in the native filesystem, so a less efficient, safer path to generating the native name is taken by normalizing the path first. Normalizing the path converts it out of the intrep which triggers the bug. On the other hand, when the pathname of the demo script is relative, we had to compute [pwd] just to find and source the script, so we have the value and we know it's in the native filesystem, so within TNCNR we take a more efficient path to computing the native name which also preserves the intrep which is needed to demo the [file tail] bug. Perhaps more than you wanted to know, but I figured it should be written down somewhere.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"