Tcl Source Code

View Ticket
Login
Ticket UUID: 2889257
Title: [array startsearch] and friends do not work on env
Type: Bug Created on: 2009-10-30 06:28:10
Submitter: mistachkin Assigned to: hobbs
Subsystem: 08. Environment Variables Severity:
Priority: 5 Medium Last modified: 2026-10-21 09:58:25
Status: Closed Closed by: msofer
Resolution: Duplicate Closed on: 2009-10-30 10:27:02
Version: obsolete: 8.6b1.1
Description:
My research indicates this is due to the EnvTraceProc function calling the function TclSetupEnv for all [array] related trace operations, which deletes the entire global env array and any/all existing array searches with it as part of the process of "synchronizing" the contents of the env array with the actual environment.  Therefore, it is impossible to actually use the array search functionality with the global env array.

This bug also seems to apply to Tcl 8.4 and 8.5.

Example:

set s [array startsearch env]; # returns OK, s-1-env
array nextelement env $s; # returns ERROR, couldn't find search "s-1-env"
User Comments:
msofer added on 2009-10-30 17:27:02:
Duplicate: #1787911.

This way since 7.6 AFAIU, hard to define proper semantics. Solution might be to only use [array names] on env

mistachkin added on 2009-10-31 08:32:52:
This limitation (not being able to ever perform array searches on the env array) should at least be documented clearly.

serhiy.storchaka added on 2026-10-21 09:58:25:

Duplicate of [1787911fff]. Array searches on env work since 8.6.2, where [afaff33553] stopped env from being recreated on array access.