Version 7 of pkgIndex.tcl

Updated 2008-05-09 14:30:29 by lars_h

Purpose: document the who/what/where/when of the pkgIndex.tcl file.

See package for the details of how the pkgIndex.tcl file is used.

See also pkgmkindex.

This is different from the unknown proc and its use of tclIndex.

PkgIndexUtil.tcl - determining a platform name

Recently in comp.lang.tcl, DKF writes (in part) [L1 ]:

Further investigation reveals a badly-written pkgIndex.tcl file, so it 
is doing: 
   package ifneeded foo 1.0 "load [file join $dir foo.dll]" 
instead of: 
   package ifneeded foo 1.0 "load [file join [list $dir] foo.dll]" 
(or one of the many variants on both those). 

I advise that all package authors should test their code when it is 
installed in a directory with a space (or square bracket) in the name, 
and if they find any problems, fix them using [list] carefully to wrap 
$dir or the value derived from it. (Remember, when you're in quoting 
hell, [list] is the road out.) 

Later in that thread, it is observed that both of the above are actually wrong.

Possible corrections of the second are:

 package ifneeded foo 1.0 [list load [file join $dir foo.dll]]     ; # File join when setting script
 package ifneeded foo 1.0 "load \[file join [list $dir] foo.dll\]" ; # File join when evaluating script

but for multiple-command scripts, DKF ends up recommending:

package ifneeded foo 1.0 [list apply {dir { 
     load [file join $dir foo.dll] 
     uplevel 1 [list source [file join $dir foo.tcl]] 
  }} $dir]