Skip to content
Tcl Source Code View Ticket
Login

View Ticket

windows: paths starting with tilde (~) are "partially" absolute

Closed / Fixede83a97c7fee9d6bc2bec78d70b205a0e4d09ea8dCreated 7 years agoUpdated 42 days ago
Descriptionwiki2019-11-08 13:23:56
Issue could be considered as continuation of [9e6b569963]...

Note the ticket is only about ~* and not ~/* (which could be firstly considered as rather absolute path).

Under windows it is possible to have relative paths (file and directory names) starting with tilde, as such it is "partially absolute" path, so in my opinion should be interpreted as relative if used in file join.
From this point of view file join $dirname $filename behaves incorrectly under windows if filename starting with ~ characters:

% file join $env(tmp) ~*
~*
% file join $env(tmp) ~abc.txt
~abc.txt

Where glob already has correct behavior here:

% glob -directory e:/temp ~*
e:/temp/~abc.txt
% glob e:/temp/~*
e:/temp/~abc.txt
% cd e:/temp
% glob [pwd]/~*
E:/Temp/~abc.txt

Just this one is a bit confusing (I know it is a bit "ambiguous", but...):

% glob ~*
user "*" doesn't exist
Despite ambiguity it looks still weird to me:
  1. either the decision remains "path of pattern is absolute", it could be fixed to list all users/homes where caller is permitted.
  2. or the decision going either to "path of pattern considered as relative" under windows, it should behave like glob [pwd]/~* (so find all files starting with "~" in current directory).

Anyway (after fix) it could be additionally documented (with difference between unix/windows).

sebres Ticket [e83a97c7fe]: 3 changes [History diff]2019-11-08 13:30:37
serhiy.storchakawiki2026-10-21 10:03:39

Since Tcl 9.0 (TIP 602, [cff0348cb6]) a path starting with ~ is an ordinary relative name, so file join and glob treat ~abc.txt and ~* as files in the directory. 8.6 keeps its documented tilde expansion. Closing as fixed in 9.0.

serhiy.storchaka Ticket [e83a97c7fe]: 3 changes [History diff]2026-10-22 17:19:31
Log in (anonymous is fine) to add a comment.