#1240 setting env variable array is broken under Windows.

obsolete: 8.2
closed-duplicate
nobody
5
2001-12-12
2000-10-26
Anonymous
No

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

Discussion

    • labels: 104254 --> 08. Environment Variables
     
    • assigned_to: nobody --> davygrvy
     
  • Logged In: YES
    user_id=7549

    I can't look at this right now.

     
    • assigned_to: davygrvy --> nobody
     
  • Jeffrey Hobbs
    Jeffrey Hobbs
    2001-12-12

    • status: open --> closed
     
  • Jeffrey Hobbs
    Jeffrey Hobbs
    2001-12-12

    Logged In: YES
    user_id=72656

    #488882 is a duplicate of this, with a few more examples.

     
  • Jeffrey Hobbs
    Jeffrey Hobbs
    2001-12-12

    • status: closed --> closed-duplicate