#4451 [array startsearch] and friends do not work on env

obsolete: 8.6b1.1

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.


set s [array startsearch env]; # returns OK, s-1-env
array nextelement env $s; # returns ERROR, couldn't find search "s-1-env"


  • miguel sofer

    miguel sofer - 2009-10-30

    Duplicate: #1787911.

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

  • miguel sofer

    miguel sofer - 2009-10-30
    • status: open --> pending-duplicate
  • Joe Mistachkin

    Joe Mistachkin - 2009-10-31

    This limitation (not being able to ever perform array searches on the env array) should at least be documented clearly.

  • Joe Mistachkin

    Joe Mistachkin - 2009-10-31
    • status: pending-duplicate --> open-duplicate

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks