Xref: utzoo comp.lang.c:36257 comp.unix.programmer:1118 Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c,comp.unix.programmer Subject: Re: setenv() call? Message-ID: <4782@goanna.cs.rmit.oz.au> Date: 18 Feb 91 08:03:36 GMT References: <1991Feb17.205749.27681@athena.mit.edu> Followup-To: comp.lang.c Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 25 In article <1991Feb17.205749.27681@athena.mit.edu>, jik@athena.mit.edu (Jonathan I. Kamens) writes: > In article , jph@ais.org (Joseph Hillenburg) writes: > |> Do any of you know of a way to implement a setenv() system call on 4.3BSD? > I'd say that "everyone you've talked to" is wrong. > > The 4.3reno BSD contains implementation of putenv, setenv and unsetenv. The question is not whether it is possible to have a function called setenv() that does something to a copy of the environment. The question is whether there is a way to do what the original poster has in mind, which he unfortunately forgot to tell us. If Joseph Hillenburg wants a function which will set variables in the environment of the parent shell (which is what people are usually looking for, and what "can't do it" is usually referring to), then the BSD functions are irrelevant, because they don't do that. In UNIX, getenv() and putenv() -- and setenv() and unsetenv() if you have them -- work on a COPY of the parent's environment. In other operating systems, it varies. See "logical names" in VMS documentation. putenv() -- if you have it -- is _likely_ to affect commands executed via system(), but not the parent CLI. -- Professional programming is paranoid programming