[vox-tech] Bash script to setup environment variables

Ted Deppner vox-tech@lists.lugod.org
Fri, 28 Dec 2001 07:32:09 -0800


On Thu, Dec 27, 2001 at 11:12:35PM -0800, Mark K. Kim wrote:
> I'm doing some cross-compilation work so I need to flip environment
> variables on/off in a heartbeat.  I tried to write a script, but scripts
> run on sub-processes so the changes do not take effect on the parent
> process.  Is there a way, without having to type `source script` or `.
> script`, to make environment variables changes take place on the running
> process?

The answer would be heavily influenced by whatever process your build
environment is.

Assuming a bash like environment, Jeff's recommendation of aliases is dead
on.  You can also use functions...  myfunc() { var1=test; var2=test; }
(yes, you need the trailing ; just before the } when typing that on a
cmdline).  You can also use "eval"...  eval "var1=test; var2=test"

Perl has quite a few options too...  let us know what your environment is,
if these don't cover it yet.

-- 
Ted Deppner
http://www.psyber.com/~ted/