开发者

What is the cause of different TCL script behaviour when redirecting the output to a file under Cygwin?

When calling script as

tclsh ./TestDriver.tcl TestList

the tcl script stops after one (?) line. But when called with output redirected to a file

tclsh ./TestDriver.tcl Tes开发者_如何学JAVAtList >bar.out

it runs smoothly. Any ideas what might be the cause of such behavior ?


Almost all Tcl scripts work identically when their output is directed to a terminal or to a file. While there is a tcl_interactive variable that things could be keyed off, it doesn't come into play when you're supplying the script as an argument. The other base-line difference is that stdout will have different buffering by default; you can change that to be defined with:

fconfigure stdout -buffering none ;# Or “line” or “full”

However, I would expect the differences there to make things (very marginally) less likely to work in the case of being redirected to a file. Whatever is going on (and I bet it either involves running subprocesses or the use of extension packages) I can't guess it on the basis of the evidence provided.


I would guess the tcl program is calling an istty function, and changing it's behavior depending on if it thinks it's writing to terminal. Possibly, it's attempting to format the output, and a wide terminal is causing it to fail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜