| Ticket UUID: | 2001389 | ||
| Title: | empty string as path: troubling exceptions | ||
| Type: | Bug | Created on: | 2008-06-24 03:09:54 |
| Submitter: | dgp | Assigned to: | vincentdarley |
| Subsystem: | 36. Pathname Management | Severity: | |
| Priority: | 5 Medium | Last modified: | 2008-06-24 10:51:02 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | obsolete: 8.6a0 | ||
| Description: | ||||
While digging into the details
of 1999176, the issue of how an
empty string ought to be handled
in a pathname context arises again
and again.
% file pathtype {}
relative
This suggests {} is a valid relative
pathname. However:
% file normalize {}
%
Unlike every other relative pathname,
the normalized form is not an absolute
pathname. Any code that assumes the
value returned from [file normalize]
or Tcl_FSGetNormalizedPath() is an
absolute path gets tripped up on this
exception.
Even worse:
% file system {}
Unrecognised path
If the empty string is a pathname, it's
a pathname that belongs to no VFS at all.
That's just broken.
| ||||
| User Comments: | ||||
dgp added on 2008-06-24 10:29:09:
Logged In: YES
user_id=80530
Originator: YES
[file normalize] and [file system]
were new in Tcl 8.4, so looking back
to Tcl 8.3 for guidance loses those.
However:
% file dirname {}
.
% file tail {}
% file isfile {}
0
% file isdirectory {}
0
% file type {}
could not read "": no such file or directory
% file rootname {}
% file nativename {}
%
If I were a judge, I'd declare a mistrial.
dgp added on 2008-06-24 10:51:02:
Logged In: YES
user_id=80530
Originator: YES
Comments at lines 2711-2716
of tclPathObj.c appear to address
this matter:
/*
* A special case is required to handle the empty path "". This is a valid
* path (i.e. the user should be able to do 'file exists ""' without
* throwing an error), but equally the path doesn't exist. Those are the
* semantics of Tcl (at present anyway), so we have to abide by them here.
*/
I don't really understand the reasoning
asserted in that comment, but at least it
indicates this difficult situation is in place
intentionally.
| ||||
