How to override the default init.tcl
Posted
by
Sean Murphy
on Stack Overflow
See other posts from Stack Overflow
or by Sean Murphy
Published on 2012-09-18T21:36:25Z
Indexed on
2012/09/18
21:37 UTC
Read the original article
Hit count: 335
I'm working on a project where I want to make use of TCL as the command interpreter. I have a working c library object which I can load from within the tcl shell but my problem is finding a way to automatically do this while starting a tclsh.
Essentially my ultimate goal is to be able to run a script and have it load my library and run some initial startup tcl code before dropping me back to the tclsh command prompt in interactive mode.
e.g. tclsh -f myscript.tcl --then-switch-to-interactive or EXPORT TCLINIT=myscript.tcl tclsh
The basic goal is to avoid having to distribute tclsh but rather rely in local user installations of tcl. All I would like to distribute is my library, a startup script and a shell command to launch the tclsh with the library preloaded.
I've tried using the environment variables TCLINIT and TCL_LIBRARY but they seem to have no effect.
The only workable solutions I've found so far are to add "source myscript.tcl" to either the end of /usr/share/tcltk/tcl8.5.init.tcl or ~/.tclshrc
However both of these "solutions" are non perfect as they require modification of the default users workspace.
It strikes me that there must be a way to handle this in TCL, but my research so far hasn't yielded anything.
Does anyone have any suggestions?
© Stack Overflow or respective owner