1SETENV(3)                  Linux Programmer's Manual                 SETENV(3)
2
3
4

NAME

6       setenv - change or add an environment variable
7

SYNOPSIS

9       #include <stdlib.h>
10
11       int setenv(const char *name, const char *value, int overwrite);
12
13       int unsetenv(const char *name);
14
15   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17       setenv(), unsetenv(): _BSD_SOURCE || _POSIX_C_SOURCE >= 200112L ||
18       _XOPEN_SOURCE >= 600
19

DESCRIPTION

21       The setenv() function adds the variable name to  the  environment  with
22       the value value, if name does not already exist.  If name does exist in
23       the environment, then its value is changed to  value  if  overwrite  is
24       non-zero;  if overwrite is zero, then the value of name is not changed.
25       This function makes copies of the strings pointed to by name and  value
26       (by contrast with putenv(3)).
27
28       The unsetenv() function deletes the variable name from the environment.
29       If name does not exist in the environment, then the function  succeeds,
30       and the environment is unchanged.
31

RETURN VALUE

33       The  setenv()  function  returns  zero  on  success, or -1 if there was
34       insufficient space in the environment.
35
36       The unsetenv() function returns zero on success, or -1 on  error,  with
37       errno set to indicate the cause of the error.
38

ERRORS

40       EINVAL name contained an '=' character.
41

CONFORMING TO

43       4.3BSD, POSIX.1-2001.
44

NOTES

46       POSIX.1-2001 does not require setenv() or unsetenv() to be reentrant.
47
48       Prior to glibc 2.2.2, unsetenv() was prototyped as returning void; more
49       recent glibc versions follow the POSIX.1-2001-compliant prototype shown
50       in the SYNOPSIS.
51

BUGS

53       POSIX.1-2001  specifies  that  if  name contains an '=' character, then
54       setenv() should fail with the error EINVAL; however, versions of  glibc
55       before 2.3.4 allowed an '=' sign in name.
56

SEE ALSO

58       clearenv(3), getenv(3), putenv(3), environ(7)
59

COLOPHON

61       This  page  is  part of release 3.22 of the Linux man-pages project.  A
62       description of the project, and information about reporting  bugs,  can
63       be found at http://www.kernel.org/doc/man-pages/.
64
65
66
67GNU                               2007-07-26                         SETENV(3)
Impressum