是否有列出 TCL 中所有源文件的命令?
例如 - 我来源a.tcl, b.tcl,c.tcl在test.tcl文件中。是否有 TCL 命令来查看源文件?
No, but you can override the source command itself to keep track of the source'd files somewhere, like this:
rename source __real_source
proc source args {
global sourced
lappend sourced $args
uplevel 1 [linsert $args 0 __real_source]
}
Update: expanding on the Donal's comment regarding the fragility of the source command there's how one could setup an execution trace:
proc register_sourced {cmd args} {
global sourced
lappend sourced [lindex $cmd end]
}
trace add execution source leave register_sourced