Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2023-03-07
02:58 • Closed ticket [9c5a00c69d]: Multiple issues with tilde expansion on Windows ... artifact: dd70db7714 user: apnadkarni
2023-03-05
11:42
Merge 8.7: Bug [9c5a00c69d]. Fix ~user on Windows check-in: 8c6befab7c user: apnadkarni tags: trunk, main
11:09
Merge 8.6: Bug [9c5a00c69d]. Fix ~user on Windows check-in: a479ad913c user: apnadkarni tags: core-8-branch
09:57
Bug [9c5a00c69d]. Fix ~user on Windows check-in: 82cc9a4f34 user: apnadkarni tags: core-8-6-branch
2023-03-04
15:11
Add test for [9c5a00c69d], tilde expansion of ~user closed check-in: 07b6e775f4 user: apnadkarni tags: bug-9c5a00c69d
15:10 • Ticket [9c5a00c69d] Multiple issues with tilde expansion on Windows status s... artifact: e34cdadae4 user: apnadkarni
12:13
Bug [9c5a00c69d]. Tilde expansion on Windows check-in: 1ea1122bf8 user: apnadkarni tags: bug-9c5a00c69d
10:34 • Ticket [9c5a00c69d] Tilde expansion on Windows does not conform to documented be... artifact: 0d745e90cc user: apnadkarni
10:23 • Ticket [9c5a00c69d]: 3 changes artifact: 764f65e0d9 user: jan.nijtmans
10:23 • Ticket [9c5a00c69d]: 3 changes artifact: 2fdc6de16e user: jan.nijtmans
03:06 • New ticket [9c5a00c69d]. artifact: a5eb6019b3 user: apnadkarni

Multiple issues with tilde expansion on Windows

Closed / Fixed9c5a00c69df3018e4077b5ea19e235f62dbe0a67Created 4 years agoUpdated 4 years ago
Descriptionmarkdown2023-03-04 03:06:38

Somewhere in the 8.6 development, probably with this commit, an inconsistency is introduced between Unix and Windows. To quote the manpages,

If a file name starts with a tilde, then the file name will be interpreted as if the first element is replaced with the location of the home directory for the given user. If the tilde is followed immediately by a separator, then the $HOME environment variable is substituted. Otherwise the characters between the tilde and the next separator are taken as a user name, which is used to retrieve the user's home directory for substitution.

Unix conforms to the documented behavior.

% set env(HOME) /tmp
/tmp
% file normalize ~
/tmp
% file normalize ~apnadkarni
/home/apnadkarni

However on Windows,

% file norm ~
C:/Users/apnad/Documents
% file norm ~ashok
C:/Users/apnad/Documents
% set env(HOME) D:\\temp
D:\temp
% file norm ~
D:/Temp
% file norm ~ashok
D:/Temp

Note how ~ashok also follows setting of HOME.

One might find the behavior on Windows more natural but it is not what is documented.

Will fix for 8.6/8.7/9.0 if there are no objections.

/Ashok

Referenced by5
jan.nijtmanswiki2023-03-04 10:23:46

No objections at all from me!

It looks like this change done, originating from [this] bugfix. It looks like you (@Ashok) was involved in that discussion)

jan.nijtmans Ticket [9c5a00c69d]: 3 changes [History diff]2023-03-04 10:23:58
apnadkarniplain2023-03-04 10:34:27
Yes, looks like it though it appears the fix did a little more than intended. Will change for 8.6 onwards.
apnadkarniplain2023-03-04 15:10:02
There are other issues with tilde on Windows as well.

NetUserGetInfo generally returns an empty string for the home directory in some scenarios,for example when the user account was originally a Microsoft account (and may be even when the current account is a Microsoft account, no means for me to test). Tcl then just assumes home directory is the directory of the same name within the default profiles directory.

The other additional issue is it looks in system.ini for the user account which is no longer valid in Windows NT.

All three are addressed in the bug-9c5a00c69d branch.
apnadkarni Closed ticket [9c5a00c69d]. [History diff]2023-03-07 02:58:55
Log in (anonymous is fine) to add a comment.