我想构造一个复杂的变量,让我们看看:
set entry_arg [lindex $argv 1]
set command_to_launch {extrernal_command_tool -option "set var $entry_arg" -other_option}
exec $command_to_lauch
Run Code Online (Sandbox Code Playgroud)
命令启动,没问题......
但是,问题是该工具得到$ entry_arg并崩溃......这是由于""不允许tcl解释de变量
set command_to_launch {extrernal_command_tool -option "set var [lindex $argv 1]" -other_option}
Run Code Online (Sandbox Code Playgroud)
有同样的问题!
我该如何解决?
您应该command_to_launch使用该list命令构造内容.
set command_to_launch [list \
extrernal_command_tool -option "set var [lindex $argv 1]" -other_option]
Run Code Online (Sandbox Code Playgroud)
你可以用以下任何一个来运行它:
exec {*}$command_to_launch ; # For 8.5 or 8.6
eval exec $command_to_launch ; # For 8.4 or before
Run Code Online (Sandbox Code Playgroud)
当然,选择正确使用的语言版本.
| 归档时间: |
|
| 查看次数: |
172 次 |
| 最近记录: |