Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-08-24
04:49 • Ticket [453514ffff] Incorrect tilde substitution on Windows status still Clo... artifact: 13a45674b9 user: kofeinik
00:20 • Closed ticket [453514ffff]. artifact: 532e0329ce user: vincentdarley
2001-08-23
01:35 • Ticket [453514ffff]: 4 changes artifact: 226a1224a3 user: hobbs
2001-08-22
17:45 • Ticket [453514ffff]: 4 changes artifact: 9027a5d867 user: vincentdarley
05:15 • Ticket [453514ffff]: 4 changes artifact: 87a239bcc5 user: hobbs
05:03 • Ticket [453514ffff]: 4 changes artifact: b6202112d1 user: dgp
04:47 • Ticket [453514ffff]: 4 changes artifact: 2e602e9997 user: kofeinik
2001-08-21
13:23 • Ticket [453514ffff]: 7 changes artifact: 123374e90b user: dgp
2001-08-20
21:39 • New ticket [453514ffff]. artifact: e788069055 user: kofeinik

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.