safe_tcl
Execute Tcl command templates with auto-escaped arguments to prevent injection and parsing errors from special characters.
Instructions
执行带参数的 Tcl 命令模板,自动用 Tcl list 规则转义参数。
适用场景:命令中含文件路径、端口名、字符串值等可能有特殊字符的输入。
Tcl 的 $、[]、{}、反斜杠、空格都会被正确转义,防注入且防解析错。
用法示例:
safe_tcl("create_project {0} {1} -part {2}", args=["my_proj", "C:/path with space", "xc7a35tcpg236-1"])safe_tcl("read_verilog {0}", args=["C:/files/top with $dollar.v"])safe_tcl("set_property PACKAGE_PIN {0} [get_ports {1}]", args=["W5", "clk"])
template 用 Python format 的 {0} / {1} 占位符,args 中每个元素会被
tcl_quote() 包装成 "..." 并转义所有特殊字符。
Args: template: Tcl 命令模板,用 {0}/{1}/... 表示参数位置。 args: 参数值列表,将被自动转义。 session_id: 目标会话 ID,默认 "default"。 timeout: 命令执行超时秒数,默认 120。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| timeout | No | ||
| template | Yes | ||
| session_id | No | default |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |