2
* Some systems do not have setenv(). This one is modeled after 4.4 BSD, but
3
* is implemented in terms of portable primitives only: getenv(), putenv()
4
* and malloc(). It should therefore be safe to use on every UNIX system.
6
* If clobber == 0, do not overwrite an existing variable.
8
* Returns nonzero if memory allocation fails.
10
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
14
static char sccsid[] = "@(#) setenv.c 1.1 93/03/07 22:47:58";
17
/* setenv - update or insert environment (name,value) pair */
19
int setenv(name, value, clobber)
28
if (clobber == 0 && getenv(name) != 0)
30
if ((cp = malloc(strlen(name) + strlen(value) + 2)) == 0)
32
sprintf(cp, "%s=%s", name, value);