Overview
| Artifact ID: | d96de9c2d28cef76aadf4d0e83b3d6157014b30a88324820ec289abc6ad1a8f6 |
|---|---|
| Ticket: | 9e6b569963ea497e9e623a79d5a5f92c5681bfdb
file normalize ~user fails on Windows |
| User & Date: | apnadkarni on 2018-05-25 12:50:26 |
Changes
- icomment:
For my own understanding, I would like to summarize the situation *specifically with respect to the function TclpGetUserHome*. The "name" parameter passed to this function may be one of the forms 1. plain name with no domain (joe). Further, 1a. joe may be a local computer system account, or 1b. joe may be an account in the default domain 2. name in SAM format (ACME\joe) 3. name in dns format ([email protected]) My understanding is that 8.6 (and I assume 8.5) only handled 1a correctly and was broken for 1b, 2 and 3. If I read the source correctly, Francois's [adbe7e0e07] changes take care of 2 and 3 as well but not 1b. [sebres-bug-9e6b569963-8-5-branch] takes care of 1a and 3 but not 2. Now when can Case 2 happen? As discussed, the ~domain\user case cannot be distinguished from ~user\path so we have to forget about worrying about that case. So the only possible path to that case seems to be if "~" by itself got mapped to a user account name of the form domain\user. Now it turns out tracing back to the code that this never happens. A ~ by itself always resolves to env(HOME). env(HOME) in turn is picked up from the environment and if it it does not exist, it is constructed from env(HOMEDRIVE) and env(HOMEPATH). If those do not exist either, it is set to the root of the system drive. Thus I believe TclpGetUserHome will never see Case 2. HOWEVER... The current behaviour of constructing a "fake" HOME environment variable if it does not exist seems just plain wrong to me. What Tcl *should* be doing if HOME is not defined is call TclpGetUserHome with the current user name retrieved via GetUserNameEx. I think this change should be made for some future release, 8.7 or 9. This for future proofing, I would suggest picking up the sebres* branch with the addition of the check for domain\user from Francois. On a stylistic issue (not bug), it would be clearer to me at least if the single while loop was broken out explicitly rather than setting domain = -1.
- login: "apnadkarni"
- mimetype: "text/plain"