#!/bin/tclsh
# i am doing this for multiple packages in a loop
set list {/usr/local/script}
lappend list -check
lappend list -package
lappend list tcl-devel
lappend list version
[eval exec $list]
invalid command name "
checking the version [ ok ] #expected output
-checks successful! #expected output
"
while executing
"[eval exec $list]"
不明白为什么我得到这个“无效的命令名称错误”可以任何人帮助
答案 0 :(得分:0)
问题是您已成功运行该命令,得到了结果,然后尝试将这些结果用作命令的名称,因为您放置[
括号{{1}围绕]
。删除括号,或在它们之前放置命令名称,以便将结果用作参数。
eval exec
set list …
# Leaving out the details of how you build the list
eval exec $list