When developing Tcl code, I find the interactive facilities of tclsh very useful, and I'll often launch tclsh interactively, source
code from files, and continue to run and debug from there.
What I'm wondering is: is there a way to drop into the interactive shell from a tclsh instance that is not interactive (say because it was run with a script file argument)? I know there's a tcl_interactive
variable, which can be set, but doing so does not result in an interactive prompt.
I'd prefer to be able to do this within the same process and terminal (though Tkcon is certainly wonderful).
(I would guess that the tricky thing would be switching Tcl's input from the specified script file to the terminal/pty's stdin. That may be something that requires Expect's magic to work. I've also pondered some trickery using .tclshrc
, but that gets messy; I wish tclsh
let you specify an rc-file on the command line or via an environment variable.)
You could start up a tclreadline REPL: