为什么“exec”在这段代码中给出了“孩子异常退出”?

时间:2011-06-30 20:06:04

标签: tcl

我在tcl中运行此代码: -

set version [exec grep "INTERNAL VERSION:" mojave.log | sed -n -e "s/INTERNAL VERSION: //g" > xor.diff]

set p [exec diff ../log.warning.diff ../log.warning.gold >> xor.diff ]

对于最后一行,它在做了一些diff之后给出了以下错误: -

> RULE-311 WARNING: Gdsii layer number 85 datatype 0 has already been defined
> TCL-11   WARNING: Command "check quartz drc" is overridden, Quality Of
> TCL-11   WARNING: Command "delete marker quartz" is overridden, Quality Of
> TCL-11   WARNING: Command "import marker quartz" is overridden, Quality Of
> TCL-11   WARNING: Command "mojave! run filter log" is overridden, Quality Of
> TCL-11   WARNING: Command "run quartz gui" is overridden, Quality Of Results
> TCL-11   WARNING: Command "ui! mojave draw rectangle" is overridden, Quality
> TCL-11   WARNING: Command "ui! mojave set_context" is overridden, Quality Of
> TCL-12   WARNING: Overridden command "mojave! run filter log" is used,
child process exited abnormally
     while executing
"exec diff ../log.warning.diff ../log.warning.gold 2> xor.diff "
     invoked from within
"set p [exec diff ../log.warning.diff ../log.warning.gold 2> xor.diff ]"
     (file "test.tcl" line 4)
     invoked from within
"source test.tcl"

并没有在“xor.diff”文件中写任何内容。

2 个答案:

答案 0 :(得分:4)

如果发现任何差异,

diff(和comm)退出非零,因此您可以重定向输出以将其用作“执行此更改?”试验。对于Tcl,你会想要使用`|| :'成语忽略退出状态。

P.S。 “无用的使用grep”...... sed -n -e '/INTERNAL VERSION: /s//gp'

答案 1 :(得分:4)

如果命令返回非零或者它向stderr发送任何内容,

exec将返回错误。关于在http://wiki.tcl.tk/exec使用catchexec进行了非常详尽的讨论