Well, two different issues here. In response to your question,
marsd, changes to environment variable through the pre-defined global
env array affect only the currently running process and any processes spawned by it. There's no way for a program to change environment variables and have those changes propagated into the calling context (without the cooperation of the calling context), because that would be a gaping security hole. Just imagine running a script that could change your
PATH environment variable without your knowing it.
But
naru21 seems to be asking about something else. I think he's asking if there's a way to have
tclsh or
wish automatically execute a set of commands on start-up, in rather that same way that you can have a ".profile" or ".bashrc" file. The answer is yes.
From the
tclsh manual page:
"If there exists a file .tclshrc (or tclshrc.tcl on the Windows platforms) in the home directory of the user, tclsh evaluates the file as a Tcl script just before reading the first command from standard input."
Similarly, the
wish manual page says:
"If there exists a file .wishrc in the home directory of the user, wish evaluates the file as a Tcl script just before reading the first command from standard input."
Actually, upon testing this on a Windows 2000 system, if there is a file named wishrc.tcl in the user's home directory,
wish evaluates the commands contained in that file. So it is parallel in operation with
tclsh. The documentation just needs updating.
Note that on all platforms, these startup scripts are executed only for interactive sessions; they aren't executed if you specify a script name when you start the interpreter (for example, executing "tclsh myscript.tcl"

. Of course, the expectation is that you could write a script to do the same thing when it starts, if that's the behavior you want. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax