Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-12-13
03:26 • Ticket [219209ffff] setting env variable array is broken under Windows. stat... artifact: f3b8f8a0b8 user: hobbs
03:26 • Closed ticket [219209ffff]. artifact: ccdf62d9d0 user: hobbs
2001-09-08
06:49 • Ticket [219209ffff]: 5 changes artifact: 5a68aaf93c user: davygrvy
06:32 • Ticket [219209ffff]: 1 change artifact: 4b1c0028b8 user: andreas_kupries
2001-02-07
22:40 • Ticket [219209ffff]: 1 change artifact: d7e36ffdeb user: dkf
2000-10-26
05:03 • New ticket [219209ffff]. artifact: 92d4510eaf user: nobody

setting env variable array is broken under Windows.

Closed / Duplicate219209ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2000-10-26 05:03:37
OriginalBugID: 3661 Bug
Version: 8.2
SubmitDate: '1999-11-23'
LastModified: '2000-04-26'
Severity: SER
Status: Assigned
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 4109 1999
OS: All Windows
FixedDate: '2000-10-25'
ClosedDate: '1999-11-24'


Name:
Mo DeJong

Comments:
I seem to remember a strange problem like this with Tcl 8.0. At the time,
the problem was that after an env var was set a variable trace would get
fired and the trace would delete an empty env var.

ReproducibleScript:
Setting an env variable to the empty string actually removes the variable
from the env array under Windows. Here is a quick example.

% set env(CLASSPATH) value
% parray env
env(BLASTER)    = A220 I5 D1 T4
env(CLASSPATH)  = value
env(CMDLINE)    = WIN
...

% set env(CLASSPATH) ""
% parray env
env(BLASTER)    = A220 I5 D1 T4
env(CMDLINE)    = WIN
... (no CLASSPATH key)

ObservedBehavior:
The env var is deleted when set to "".

DesiredBehavior:
I want to env var to be set properly.
This same code works fine under Linux.


This is the defined behavior of Windows env variables,
but isn't acceptable because the following fails:

if {! [info exists env(CLASSPATH)]} {
  set env(CLASSPATH) ""
}
set env(CLASSPATH) $env(CLASSPATH);C:\\dir

The interim work-around is to do a read trace on the env
array for Windows. 
-- 11/24/1999 hobbs

--

What about:

--------------------------------------
set tmpClasspath ""
if { [info exists env(CLASSPATH)] } {
set tmpClasspath $env(CLASSPATH)
}
set tmpClasspath "$tmpClasspath;C:\\dir"
...
set env(CLASSPATH) $tmpClasspath
--------------------------------------

This has the additional benefit of avoiding the overhead of working with the env array except when it's absolutely necessary.

Removing environment variables when they are set to null is the normal behavior on Windows; I don't know if it is right to change that behavior.

-- 04/10/2000 ericm 
-- 04/26/2000 hobbs
dkf Ticket [219209ffff]: 1 change [History diff]2001-02-07 22:40:21
andreas_kupries Ticket [219209ffff]: 1 change [History diff]2001-09-08 06:32:22
davygrvyplain2001-09-08 06:49:42
Logged In: YES 
user_id=7549

I can't look at this right now.
hobbs Closed ticket [219209ffff]. [History diff]2001-12-13 03:26:39
hobbsplain2001-12-13 03:26:40
Logged In: YES 
user_id=72656

#488882 is a duplicate of this, with a few more examples.
Log in (anonymous is fine) to add a comment.