Tcl Source Code

View Ticket
Login
Ticket UUID: b492c33154cda419be5400f0018b5599cca96ae2
Title: Inconsistent behaviour with env array on Windows
Type: Bug Created on: 2026-05-06 15:59:34
Submitter: apnadkarni Assigned to: nobody
Subsystem: 08. Environment Variables Severity: Minor
Priority: 5 Medium Last modified: 2026-05-21 08:16:12
Status: Closed Closed by: apnadkarni
Resolution: Fixed Closed on: 2026-05-21 08:16:12
Version: 8.6
Description:

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
User Comments:
chw added on 2026-05-13 20:24:20:
How about the approach in the attached diff?

apnadkarni added on 2026-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.)

chw added on 2026-05-14 15:38:00:
Howdy Ashok, NP, take your time for real important work. This issue isn't pressing at all.

apnadkarni added on 2026-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


chw added on 2026-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.

apnadkarni added on 2026-05-21 08:16:12:
Fixed in [8e0656d976] for 9.0.4

Attachments: