Testing and reading env variables on Windows 
Author Message
 Testing and reading env variables on Windows

Tcl 8.2b2 Bug:  Generated by Scriptics' bug entry form at
Responses to this post are encouraged.

Submitted by:  Ingemar Hansson
OperatingSystem:  Windows NT
OperatingSystemVersion:  v4.0 SP5
Synopsis:  Testing and reading env variables on Windows

    Set an environment variable (at DOS-level):
    set tVar=1

    # This test will return 0
    if {[info exists env(TVAR)]} {
        set tv $env(TVAR)
    # The variable tv will be set !!!
    set tv $env(TVAR)

    # Now this test will return 1 !!!
    if {[info exists env(TVAR)]} {
        set tv $env(TVAR)

    "info exists" doesn't find env variables that an access the env array

    There seems to be some undocumentet feature when accessing the env
    variable. Character case of index to the array doesn't matter (even
    though the documentation says it does). I like that (!!!) because that's
    the behaviour in the operating system. (Maybe it's an OS API that does
    But the "info exists" command fails until an access with equal character
    case is done.

    This isn't too hard to work around. Instead of the following

    if {[info exists env(TVAR)]} {
        do something


    if {![catch {set env(TVAR)}]} {
        do something

Sun, 27 Jan 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. can't read env(DISPLAY) from regexp with $env(DISPLAY)

2. Bug in Tcl 8.3.3 for Windows with variable env

3. setting env variable array is broken under Windows.

4. printing from clipper prog in windows env to windows printer

5. unicode (test env-4.3) problem

6. parsing env variable

7. how to substitute an env variable in sed

8. Access Amiga ENV: Variables in JForth (Short)

9. Creating variables in the top level env of Hugs

10. Setting env variables in Linux

11. Referencing Text I/O files with ENV variables

12. Setting env. variables


Powered by phpBB® Forum Software