 <p>The environment is exposed via the global <code>env</code> array in Tcl. The keys and values of the array default to the environment inherited from the parent process, any process that Tcl creates will inherit a copy of it, and code that examines the environment in the current process (including directly from C) will see the current state of it.</p> <p>Picking up environment set in a shell script is quite tricky. The issue is that a <code>.bashrc</code> (for example) can do quite complex things as well as setting a bunch of environment variables. For example, it can also print out a message of the day, or conditionally take actions. But you can at least make a <em>reasonable</em> attempt by using the shell's <code>env</code> command:</p> <pre><code>set data [exec sh -c "source /path/to/file.sh.rc; env"] # Now we parse with some regular expression magic foreach {- key value} [regexp -all -inline {(?wi)^(\w+)=((?!')[^\n]+|'[^']+')$} $data] { set extracted_env($key) [string trim $value "'"] } </code></pre> <p>It's pretty awful, and isn't <em>quite</em> right (there are things that could confuse it) but it's pretty close. The values will be populated in the <code>extracted_env</code> array by it.</p> <p>I think it's easier to get people to configure things via Tcl scripts…</p>