If tclsh is running a script, it doesn't exit on detecting an EOF on stdin; that's purely a feature of the built-in REPL. You can detect such a condition yourself using eof stdin
, at which point you can decide what to do about it.
If you're wanting to make a Ctrl+D not be EOF, then your easiest method is to put the terminal into raw mode, like this:
set sttySettings [exec stty -g <@stdin]
exec stty -echo raw <@stdin
When you're done, switch back like this:
exec stty $sttySettings <@stdin
Make sure you switch back before the program exits!
The other thing is that if you're working with raw input, you've got to handle all line editing yourself. A convenient way to do this is to use a pure Tcl readline-alike system such as this example from the Tcler's Wiki. You might need to adapt it a bit to make Ctrl+D do what you want.
An alternative is to do this which leaves things in cooked mode and just makes Ctrl+D non-special (tested on OSX):
exec stty eof "" <@stdin
Again, you need to set things back on exit, and the fact that it's not special at all might cause problems elsewhere; after that trick above, it's just a normal character.