Command to list all source files in TCL

Is there a command to list all source files in TCL?

Eg Source - I a.tcl

, b.tcl

, c.tcl

in the file test.tcl

. Is there a TCL command to view source files?

+3


source to share


1 answer


No, but you can override the command source

to track files source

' d somewhere, for example:

rename source __real_source
proc source args {
    global sourced
    lappend sourced $args
    uplevel 1 [linsert $args 0 __real_source]
}

      



Update: Expanding on Donal's comment regarding the fragility of the command source

where the execution trace can be configured:

proc register_sourced {cmd args} {
  global sourced
  lappend sourced [lindex $cmd end]
}
trace add execution source leave register_sourced

      

+7


source







All Articles