2011-06-30 141 views
2

我在TCL運行此代碼: -爲什麼「exec」在此代碼中給「孩子退出異常」?

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 ] 

最後一行它提供了以下錯誤做一些差異後: -

> 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」寫任何東西文件。

回答

4

exec如果命令返回非零或者它向stderr發送了任何內容,則返回一個錯誤。有一個非常詳細的討論,使用catchexechttp://wiki.tcl.tk/exec

4

diff(和comm)如果找到任何差異,則退出非零,因此您可以重定向輸出以將其用作「做了此更改?」。試驗。對於Tcl你需要使用`|| :'成語忽略退出狀態。

P.S. 「無用的grep」... sed -n -e '/INTERNAL VERSION: /s//gp'

+1

如果我們在「catch」中寫入「exec」命令它的作品。感謝幫助。 –

+0

+1 for「useless grep」;使我免於迴應 –

相關問題