tags:

views:

49

answers:

2

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 TestList >bar.out

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

A: 

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.

brianegge
+1  A: 

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.

Donal Fellows