2013-12-09 41 views

回答

1

據我所知,在Tcl的stdout流是「標準輸出」,和標準錯誤是「標準錯誤」。如果有一個puts $stream "string",$ stream的值爲「stdout」,則轉到stdout;與stderr類似。

puts的正常調用將流參數視爲可選;你的myPuts需要做同樣的事情,把一個缺少的操作數當作標準輸出。除此之外,我認爲這只是

if {$stream eq "stdout"} { 
    # do your stdout thing 
} elseif {$stream eq "stderr"} { 
    # do your stderr thing 
} else { 
    # do your file handle thing 
} 
+2

對於字符串比較的問題,使用'eq',而不是''== - http://tcl.tk/man/tcl8.5/TclCmd/expr。 htm#M14 –

+0

這是一個公平的警察 - 編輯,以反映你的觀點。 –

相關問題