trace
trace option ?arg ...?
Runs a command when a variable is read, written, or unset, or when a command is renamed, deleted, or run.
Subcommands
| Synopsis | What it does |
|---|---|
trace add variable NAME OPS CMD |
OPS is a list of read, write, unset, and array. CMD gets the name, the element, and the op. |
trace add command NAME OPS CMD |
OPS is a list of rename and delete. |
trace add execution NAME OPS CMD |
OPS is a list of enter, leave, enterstep, and leavestep. |
trace remove TYPE NAME OPS CMD |
Removes a trace. |
trace info TYPE NAME |
The traces of a name. |
trace variable NAME OPS CMD |
The old form of trace add variable. |
trace vdelete NAME OPS CMD |
The old form of trace remove variable. |
trace vinfo NAME |
The old form of trace info variable. |
Examples
A click on an example runs it in the shell of the page.
set log {}; set v 0; trace add variable v write {apply {{n e op} {lappend ::log $op}}}; set v 1; set log:write
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.