1GETENV(3)                  Library Functions Manual                  GETENV(3)
2
3
4

NAME

6       getenv, setenv, unsetenv - manipulate environmental variables
7

SYNOPSIS

9       char *getenv(name)
10       char *name;
11
12       setenv(name, value, overwrite)
13       char *name, value;
14       int overwrite;
15
16       void unsetenv(name)
17       char *name;
18

DESCRIPTION

20       Getenv  searches  the environment list (see environ(7)) for a string of
21       the form name=value and returns a pointer to the string value if such a
22       string is present, and 0 (NULL) if it is not.
23
24       Setenv searches the environment list as getenv does; if the string name
25       is not found, a string of the form name=value is added to the  environ‐
26       ment.   If it is found, and overwrite is non-zero, its value is changed
27       to value.  Setenv returns 0 on success and -1 on failure, where failure
28       is caused by an inability to allocate space for the environment.
29
30       Unsetenv  removes  all occurrences of the string name from the environ‐
31       ment.  There is no library provision for completely removing  the  cur‐
32       rent  environment.   It is suggested that the following code be used to
33       do so.
34
35            static char    *envinit[1];
36            extern char    **environ;
37            environ = envinit;
38
39       All of these routines permit, but do not  require,  a  trailing  equals
40       (``='') sign on name or a leading equals sign on value.
41

SEE ALSO

43       csh(1), sh(1), execve(2), environ(7)
44
45
46
477th Edition                     March 20, 1987                       GETENV(3)
Impressum