Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site hadron.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!trwatf!rlgvax!prcrs!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.unix-wizards Subject: Re: Setting environment variables within a C program. Message-ID: <178@hadron.UUCP> Date: Mon, 6-May-85 22:50:00 EDT Article-I.D.: hadron.178 Posted: Mon May 6 22:50:00 1985 Date-Received: Fri, 10-May-85 08:20:18 EDT References: <10166@brl-tgr.ARPA> Organization: Hadron, Inc., Fairfax, VA Lines: 18 > freds_wife = Wilma > export fred_wife > How do I change the value of freds_wife from Wilma to Betty within the C > program, and get the environment to understand the change later? You can't. Environment variables are exported to children, not vice- versa. The C prog is child of the shell. However, if the program produces no other output, you can get the shell to change itself by printing out the commands: printf("freds_wife=Betty; export freds_wife\n"); and then: $ eval `prog` This can be used profitably with, e.g., 'tset' to set TERM and TERMCAP. However, a second, more difficult obstacle is that Betty loves Barney and Wilma won't divorce Fred. ;-) Joe Yao hadron!jsdy@seismo.{ARPA,UUCP}