0

Run tclsh command without any tcl file, the interpreter will go into interactive mode.

Can I simply disable this feature by modifying the tclsh source code ?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
zhangailin
  • 926
  • 2
  • 10
  • 20

1 Answers1

0

I can't imagine why you would want to bother doing this, given that supplying any script file will turn off interactive mode. The script you supply will have full access to the additional arguments passed in (a list in the global argv variable) and the standard IO channels (stdin, stdout and stderr). It can exit when it is done. Literally anything you want can be done at that point; you've just got to write a script to do it.

If you're including Tcl in your own program, the behaviour of tclsh is implemented in the C function Tcl_Main. If you never call that — instead just using Tcl_FindExecutable, Tcl_CreateInterp and Tcl_Eval/Tcl_EvalFile — then you never get any of that interactive behaviour. While theoretically you could modify the Tcl source itself to do what you want — it's all open source — why would you bother when you could just not call that code in the first place?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215