[TCL] Help debugging behavior in new source command
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

[TCL] Help debugging behavior in new source command

From: Andrew Falanga <not_real@hp.com>
Date: Thu Apr 13 2006 - 17:36:46 CEST

Hello,

I'm working on a new source command that will manage a list of loaded
libraries for me. The code for the new source command is:

   rename source _source

   proc source { pathToFile } {
      global libraryIndex
      if { ![file exists $pathToFile] } {
         Log "File: $pathToFile does not exist"
         exit
      }

      uplevel #0 [list _source] $pathToFile

      regsub -all {/} $pathToFile " " pathToFile

      lappend libraryIndex [lindex $pathToFile end]
   }

I read in some past postings that commands such as uplevel work better
when all of it's arguments are passed as TCL lists (hence the use of
[list _source] (actually, my construction for the uplevel command is
based on a reply post to someone doing something similar as I with the
source command).

This redefinition of source takes place in the common library for
several scripts that depend on several libraries that I'm writing. All
seems to work ok, except when a library that I have goes to try and load
in a package, math::bignum, that a few of the procs in that library make
use of. When this library is sourced, it adds the path to the tcllib
set of packages to auto_path and then tries a package add for math::bignum.

When the package add is attempted, I get the following errors for ALL
packages in tcllib:

error reading package index file
/opt/tcllib/lib/tcllib1.7/doctools/pkgIndex.tcl: can't read "dir": no
such variable

error reading package index file /opt/tcllib/lib/tcllib1.7/pkgIndex.tcl:
can't read "dir": no such variable

So long as the source command isn't renamed, all works, but if it's
renamed I can't even source this library properly even if calling
_source libname from the tclsh prompt. Can someone help me understand
where this dir variable is coming from? I can't find its definition
anywhere (at least not before its first use in the pkgIndex.tcl file in
the tcllib root. If the source command is left unchanged, it works just
fine.

Any help is appreciated.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.
Received on Sun Apr 30 03:10:31 2006