So I am working with a large TCL project and thought it would be cool to build a treeview of how files were being source in the project. I modified the source command to do the following:
rename ::source ::real_source
proc ::source args {
set file_handle [open "file_source.tcl" a]
puts $file_handle $args
puts $file_handle $argv0
close $file_handle
uplevel 1 ::real_source $args
}
Which works and saves all of the files being sourced but I was wondering if anyone had any ideas on how I could determine which files are calling the source command?
Another interesting issue I am running into is that my new source procedure seems to only work in some files. File A sources File B and all of the sources in File B seem to work correctly but anything under that seems to go back to using the old source procedure. Any ideas on why this is happening?
[info script]will give you the name of the file invokingsourceExample:
a.tcl
b.tcl
c.tcl
outputs