Inconsistent behaviour with env array on Windows
Closed / Fixedb492c33154cda419be5400f0018b5599cca96ae2Created 211 days agoUpdated 196 days ago
Descriptionmarkdown2026-05-06 15:59:34
The following inconsistent behavior is seen on Windows. Setting an env variable to the empty string unsets it (as documented) but info exists thinks it is still defined.
% info exists env(TMP)
1
% set env(TMP)
D:\Temp
% set env(TMP) ""
% info exists env(TMP)
1
% set env(TMP)
can't read "env(TMP)": no such variable
Referenced by5
a4de0dcbabClosed ticket [1758527fff]: env bug on platform windows plus 4 other changes ticket2026-10-21 09:58:252ae307305bMerge 9.0 - Fix [b492c33154] - info exists env(xxx) and set env(xxx) are inconsistent after setting to empty string check-in2026-05-21 08:10:568e0656d976Fix [b492c33154] - info exists env(xxx) and set env(xxx) are inconsistent after setting to empty string check-in2026-05-21 08:07:56ff71d077d6Fix [b492c33154] - fix [info exists] and [set] inconsistency for env on Windows check-in2026-05-21 08:03:128e4061a167Bug [b492c33154] - info exists env(xxx) and set env(xxx) are inconsistent after setting to empty string on Windows check-in2026-05-20 08:02:31
apnadkarni Ticket [b492c33154]: 3 changes
[History diff]2026-05-06 17:00:22
chwplain2026-05-13 20:24:20
How about the approach in the attached diff?
apnadkarniplain2026-05-14 10:39:54
Thanks, Christian. I am a bit under the gun to get TIP's in before May 27. But will take a look after if no one else does. (I'm presuming you do not have commit privileges yourself.)
chwplain2026-05-14 15:38:00
Howdy Ashok, NP, take your time for real important work. This issue isn't pressing at all.
apnadkarnimarkdown2026-05-20 08:06:52
@chw, unfortunately, patch did not fix the problem. Instead, I'm now calling Tcl_UnsetVar2 which will invoke a recursive trace but I don't think that is a problem.
Proposed implementation in bug-b492c33154
chwplain2026-05-21 03:44:55
Ashok, I see, you're right. The unset will perform the real work of clearing out the environment variable in a second trace firing.
apnadkarniplain2026-05-21 08:16:12
Fixed in [8e0656d976] for 9.0.4
Log in (anonymous is fine) to add a comment.
Attachments:
- tclEnv.c-diff [download] added by chw on 2026-05-13 20:24:35. [details]