On 13/06/2015 00:14, James wrote:
> How to run tcl script in verbose mode equivalent to 'bash -x' or 'perl -d'?
>
You've got the tools, but you have to do just a little work. You need a
driver script, like this:
# A trivial logging procedure; customise how you want
proc verboselog {command operation} {
puts >>>$command
}
# KEY TRICK: Register the logger on the [source] command
trace add execution source enterstep verboselog
# Delegate to the code you want to trace
source yourRealScript.tcl
The caveats are that this produces quite a lot of output, that it
doesn't trace anything that happens after the [source] returns (notably
events; you might need a [vwait] in your script) and that it has a *big*
impact on performance (it inhibits most compilation).
Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.