Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: bc8c52ccb0b35c12e0ee68859b58b27bc8aea0536cd8b9527ca34ec1bf5b7ae5
Ticket: 1758527fffffffffffffffffffffffffffffffff
env bug on platform windows
User & Date: Busirane on 2020-04-30 16:12:02
Changes

  1. assignee changed to: "aku"
  2. closer changed to: "nobody"
  3. comment changed to:
    test procedure:
    -----------------------------------------
    % set env(Test) "Value"
    Value
    % info exists env(Test)
    1
    % puts $env(Test)
    Value
    % set env(Test) ""
    % info exists env(Test)
    1
    % puts $env(Test)
    can't read "env(Test)": no such variable
    -----------------------------------------
    
    [info exists ..] returns 1 but the variable cannot be dereferenced.
    
    % puts $tcl_patchLevel
    8.4.13
    % parray tcl_platform
    tcl_platform(byteOrder) = littleEndian
    tcl_platform(machine)   = intel
    tcl_platform(os)        = Windows NT
    tcl_platform(osVersion) = 5.0
    tcl_platform(platform)  = windows
    
    Same on Windows XP (Windows NT 5.1) with TCL 8.4.11,
    no problem on Linux and Unix (AIX), "" is returned.
    
    additional infos from comp.lang.tcl
    ========================================
     Still stranger: when you do an "array names env" before "info exists
    env(Test)" it vanishes in TCL.
    
    (bin) 38 % info patchlevel
    8.4.13
    (bin) 39 % set env(Test) "X"
    X
    (bin) 40 % info exists env(Test)
    1
    (bin) 41 % set env(Test) ""
    (bin) 42 % info exists env(Test)
    1
    (bin) 43 % array names env
    HOME PROCESSOR_IDENTIFIER ComSpec DEVMGR_SHOW_DETAILS
    DEVMGR_SHOW_NONPRESENT_DEVICES JSERV HOMEDRIVE ALLUSERSPROFILE
    FP_NO_HOST_CHECK SESSIONNAME PROCESSOR_REVISION PATHEXT LOGONSERVER
    VS80COMNTOOLS USERDOMAIN PROCESSOR_LEVEL DEFAULT_CA_NR USERPROFILE
    USERNAME COMPUTERNAME TREECTRL_LIBRARY TMP SystemRoot
    PROCESSOR_ARCHITECTURE OS ProgramFiles APPDATA CommonProgramFiles
    WV_GATEWAY_CFG windir Path TEMP HOMEPATH VU_LIBRARY SystemDrive
    PERL5LIB NUMBER_OF_PROCESSORS
    (bin) 44 % info exists env(Test)
    0
    (bin) 45 %
    ========================================
    So it seems that [array names] does some magic when the array in
    question is 'env' - namely unsetting the internal 'env' array and then
    re-populating it by asking Windows for all existing environment
    variables - et voilĂ  they're both in sync again.
    
  4. icomment:
    Is this the same bug? The result changes with every other invocation. 
    The same thing happens with C?????? for COMSPEC and ComSpec. Notably, Path 
    and ComSpec are the two environment variables that are supposed to get 
    special treatment on Windows, by being uppercased. This causes problems with 
    tcltest 2.4.0 when cleanupTests tries to restore the environment array.
    
    (Desktop) 1 % array names env P???
    PATH Path
    (Desktop) 2 % array names env P???
    PATH
    (Desktop) 3 % array names env P???
    PATH Path
    (Desktop) 4 % array names env P???
    PATH
    (Desktop) 5 % info patchlevel
    8.6.6
    (Desktop) 6 % parray tcl_platform
    tcl_platform(byteOrder)     = littleEndian
    tcl_platform(engine)        = Tcl
    tcl_platform(machine)       = intel
    tcl_platform(os)            = Windows NT
    tcl_platform(osVersion)     = 10.0
    tcl_platform(pathSeparator) = ;
    tcl_platform(platform)      = windows
    tcl_platform(pointerSize)   = 4
    tcl_platform(threaded)      = 1
    tcl_platform(user)          = HTSP1395
    tcl_platform(wordSize)      = 4
    
  5. login: "Busirane"
  6. mimetype: "text/plain"
  7. severity changed to: "Minor"
  8. username: "Busirane"