This seems to be utilizing tput, and assuming that tput uses stdin to get it's parameters, but that seems to not be the case. And things like:
echo 'puts [exec tput lines]' | tclsh
does not work (nor does it in script), same with:
"tput lines", though, works on interactive tclsh. This was rather nasty thing, but #tcl user rkeene helped me to find workaround/fix to this:
echo 'puts [exec tput lines 2>@ stderr]' | tclsh
works, as does:
echo 'puts [exec -ignorestderr tput lines]' | tclsh
(of course works in script too) so it seems (as far as I understand) tput needs to be connected to tty's stderr to work correctly. Currently tcllib functions always return 80 for columns and 24 for rows. And current solution to this is rather obscure to say the least...