Incorrect tilde substitution on Windows
Closed / Invalid453514ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-08-20 21:39:11
% info tclversion 8.3 % info patchlevel 8.3.3 % set tcl_platform(platform) windows % file join c:/temp/mydir ~mysubdir ~mysubdir % In windows environment, the character "~" hasn't any special sign. But "file join" interprets ~ as path type modifier. This is wrong.
dgpplain2001-08-21 13:23:28
Logged In: YES
user_id=80530
Note the TILDE SUBSTITUTION section of
http://tcl.activestate.com/man/tcl8.4/TclCmd/filename.htm
An excerpt:
"The Macintosh and Windows platforms do not support
tilde substitution when a user name follows the tilde.
On these platforms, attempts to use a tilde followed by
a user name will generate an error."
So apparently the correct behavior above would be to
throw an error.
Assigning to appropriate category/maintainer for
further review.
kofeinikplain2001-08-22 04:47:16
Logged In: YES user_id=286083 I think, generating an error in this case can cause less portability, because under Windows ~ is ordinary character, and sometimes present in directory structure. In case of generating of error under Windows i must always create individual functions, that operates with directories safely, and in fact, fully duplicates internal functionality of "file" command. Itsn't beatiful solution. IMHO, more correct solution is in simply ignore this symbol under windows.
dgpplain2001-08-22 05:03:08
Logged In: YES user_id=80530 One thing to consider is whether Tcl has ever behaved as documented on this point? If not, then perhaps changing the documented behavior to something more reasonable is a good idea. Can someone determine the history, please?
hobbsplain2001-08-22 05:15:12
Logged In: YES user_id=72656 I wanted to note that Tcl does do the right thing for split: (hobbs) 49 % file split /a/b/~c/ / a b ./~c and tail as well: (hobbs) 50 % file tail /a/b/~c/ ./~c Of course, if a user just receives '~c' as a relative diretory while in /a/b/, Tcl won't naturally do the right thing unless the programmer checks for ~ first. Perhaps the Windows/Mac file join should be sensitive to that.
vincentdarleyplain2001-08-22 17:45:18
Logged In: YES user_id=32170 Tcl does behave as documented, but the documentation isn't very clear. On Mac/Win/Unix Tcl treats '~' and '~user' in exactly the same way. Any path beginning '~' is an absolute path. '~user' will throw an error when Tcl tries to interpret what '~user' means (but it is quite subtle when that might actually happen). What the man page cited below is trying to say is that when Tcl tries to interpret '~user' it will always fail, because there is never any named user on Win/Mac, so you will get 'no user "user"' error messages. In fact in recent Win/MacOS releases there are such things as users, so we might wish to add support for them. This is one area where Tcl's filesystem cross-platformness needs re-examining. I'm really not sure what the best solution is.
hobbsplain2001-08-23 01:35:57
Logged In: YES user_id=72656 Vince has a good point - especially with OS X now being Unix based. I suggest that better documentation is necessary.
vincentdarleyplain2001-08-24 00:20:34
Logged In: YES user_id=32170 I've updated the documentation, which I'll commit to cvs with a bunch of other stuff. Note that MacOS X will actually use unix-Tcl not mac-Tcl, so Jeff's side-point isn't quite relevant here.
kofeinikplain2001-08-24 04:49:10
Logged In: YES user_id=286083 I have correctly understood, what functionality of ~ in any way has not varied, and all changes have touched only documentation?
Log in (anonymous is fine) to add a comment.