Tcl Source Code

View Ticket
Login
Ticket UUID: 488882
Title: problem with [info exists env(*)]
Type: Bug Created on: 2001-12-04 13:45:47
Submitter: nobody Assigned to: hobbs
Subsystem: 08. Environment Variables Severity:
Priority: 5 Medium Last modified: 2005-07-12 14:57:58
Status: Open Closed by: dkf
Resolution: Remind Closed on: 2003-02-25 09:22:09
Version: obsolete: 8.3
Description:
Hi all,

I noticed a problem using "info exists" with the env (Environment Variable) array.
I used Active State Tcl 8.3.3 and 8.3.4  and my OS is Windows 2000 (SP 5).

Here is my Tcl-script:

% set env(A) A
A
% puts $env(A)
A
% set env(A) ""
% puts $env(A)
can't read "env(A)": no such variable  <-- Here it seems that env(A) does NOT exist ...
% info exists env(A)
1     <-- ... but "info exist" knows something about env(A) ....
% array name env A
% info exists env(A)
0     <-- ... but here it is away again!?

I found some Bug reports from older releases (217835, 218754) regarding this problem.
But they are cosed (long time ago). 

Here is an output from Tcl 8.0.5 which looks fine (in my opinion):
% set env(A) A
A
% puts $env(A)
A
% set env(A) ""
% puts $env(A)

% info exists env(A)
1
% array name env A
A
% info exists env(A)
1

Thanks and regards

Arne  ([email protected])
User Comments:
dkf added on 2001-12-04 23:12:49:
Logged In: YES 
user_id=79902

I believe this is because Microsoft (in their infinite
wisdom) define an empty environment variable to be
non-existant.

hobbs added on 2001-12-13 03:27:30:
Logged In: YES 
user_id=72656

dkf is correct, the problem is that env variables that are 
set to "" will be removed.  You can find this behavior 
repeated in the Windows DOS console.  This is a dup of 
219209, but this behavior should be fixed such that Tcl 
masks this Windows oddity.

nobody added on 2001-12-13 15:48:37:
Logged In: NO 

Thanks for the response, and for your help!
There is only one question open(;-)) Tcl 8.0.5 does not have this problem.
What has changed (in Tcl 8.3.4)?

Thanks again, and kind regards

Arne

dkf added on 2003-02-25 16:22:09:
Logged In: YES 
user_id=79902

What changed was that we decided we considered accurate 
mirroring of the process's environment variables to be 
preferable to precise cross-platform compatability.

hobbs added on 2003-03-02 07:10:20:
Logged In: YES 
user_id=72656

I believe that Mo actually wanted to look into masking this 
behavior, rather than reflecting the MS behavior.

mdejong added on 2003-03-12 07:41:59:
Logged In: YES 
user_id=90858

I gave up on the masking thing. It seems like this would be
a good idea, but I seemed to reember being talked out of
it. Punting.

jaspert added on 2005-07-12 14:57:58:
Logged In: YES 
user_id=456242

This problem still exists in 8.4.9.1 and WinXP...surely it's
a bug, since 'info exists env(foo)' should always tell you
whether or not 'puts $env(foo)' is going to raise an
exception? Either the variable exists, or it doesn't.