Setting environment from inside a pg.

Alan M. Carroll carroll at cs.uiuc.edu
Wed Nov 28 10:53:30 AEST 1990


Here is how you set environment variables in a parent shell in UNIX:

Let us say you have a program named "bob" that wants to set environment
variables. Under sh you would write a function like

dave() { eval `bob` ; }

Under ksh or csh, you would use an alias. The bob program then generates
output that looks like

VAR=VALUE
VAR2=VALUE2
...

for sh or ksh, and some bizarro-nonsense format that may or may not have an
"=" sign in it for csh.

You then use "dave" instead of "bob" to set the variables. "bob" in effect
generates commands for the shell, and "dave" causes the shell to execute them.
-- 
Alan M. Carroll                "It's psychosomatic. You need a lobotomy,
Epoch Development Team          I'll get a saw."
CS Grad / U of Ill @ Urbana    ...{ucbvax,pur-ee,convex}!cs.uiuc.edu!carroll



More information about the Comp.lang.c mailing list