Tcl Source Code

View Ticket
Login
Ticket UUID: 1787911
Title: array search of env
Type: Bug Created on: 2007-09-04 16:43:12
Submitter: dgp Assigned to: msofer
Subsystem: 07. Variables Severity:
Priority: 6 Last modified: 2026-10-22 17:19:30
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-10-21 10:03:37
Version: obsolete: 8.5a7
Description:
Noted on the chat:

% set a [array startsearch env]
s-1-env
% array anymore env $a
couldn't find search "s-1-env"
User Comments:
msofer added on 2007-09-05 02:09:48:
Logged In: YES 
user_id=148712
Originator: NO

Same result on 8.34, 8.4.14, 8.5a6 (pre varReform), HEAD.

msofer added on 2007-10-28 00:11:49:
Logged In: YES 
user_id=148712
Originator: NO

The problem is with the way EnvTraceProc works: for array traces it calls TclSetupEnv, which in turns first deletes the env variable and then recreates it. The deletion cancels all searches.

What this means is that the env array cannot be searched at all. This should be either fixed or documented. 

Wary to muck with this stuff, especially since:
(a) the bug is prehistoric, raised few complaints, no tests available
(b) the bug combines two touchy issues (array searches and env), a fix may introduce subtle new bugs

Requesting comments.

serhiy.storchaka added on 2026-10-21 10:03:37:

Fixed in 8.6.2 by [afaff33553] (ticket [219226]): env is no longer unset and recreated on array access, so [array startsearch env], anymore and nextelement work.