Is tclsh running interactively?

jrw32982 This is the only way I've found that works on a plain vanilla tcl 8.4 to detect if stdin is set to a terminal or a file/pipe/socket

set interactive [ expr ! [ catch { exec /bin/sh -c { [ -t 0 ] }}]]

RFox - 2013-05-29 11:13:27

What about checking the value of tcl_interactive?

jrw32982 tcl_interactive doesn't tell you if you're running interactively (if your script can receive input from a terminal). It tells you if you're running a script.

PYK 2015-03-12: AMG and others have suggested variations on

catch {fconfigure stdout -mode}


catch {fconfigure stdout -xchar}

See Also

SQLite checkin 559835e5
The source for the information on the page.