]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
11 | .\" | |
12 | .\" Since the Linux kernel and libraries are constantly changing, this | |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
19 | .\" | |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" References consulted: | |
24 | .\" Linux libc source code | |
25 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
26 | .\" 386BSD man pages | |
27 | .\" Modified Sat Jul 24 18:20:58 1993 by Rik Faith (faith@cs.unc.edu) | |
28 | .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl) | |
305a0578 | 29 | .\" Modified 9 Jun 2004, Michael Kerrisk <mtk-manpages@gmx.net> |
fea681da MK |
30 | .\" Changed unsetenv() prototype; added EINVAL error |
31 | .\" Noted non-standard behaviour of setenv() if name contains '=' | |
279d6eea | 32 | .\" 2005-08-12, mtk, glibc 2.3.4 fixed the "name contains '='" bug |
fea681da MK |
33 | .\" |
34 | .TH SETENV 3 2004-05-09 "BSD" "Linux Programmer's Manual" | |
35 | .SH NAME | |
36 | setenv \- change or add an environment variable | |
37 | .SH SYNOPSIS | |
38 | .nf | |
39 | .B #include <stdlib.h> | |
40 | .sp | |
41 | .BI "int setenv(const char *" name ", const char *" value ", int " overwrite ); | |
42 | .sp | |
43 | .BI "int unsetenv(const char *" name ); | |
44 | .fi | |
45 | .SH DESCRIPTION | |
63aa9df0 | 46 | The \fBsetenv\fP() function adds the variable \fIname\fP to the |
fea681da MK |
47 | environment with the value \fIvalue\fP, if \fIname\fP does not |
48 | already exist. If \fIname\fP does exist in the environment, then | |
49 | its value is changed to \fIvalue\fP if \fIoverwrite\fP is non-zero; | |
50 | if \fIoverwrite\fP is zero, then the value of \fIname\fP is not | |
51 | changed. | |
52 | .PP | |
63aa9df0 | 53 | The \fBunsetenv\fP() function deletes the variable \fIname\fP from |
fea681da MK |
54 | the environment. |
55 | .SH "RETURN VALUE" | |
63aa9df0 | 56 | The \fBsetenv\fP() function returns zero on success, or \-1 if there |
fea681da | 57 | was insufficient space in the environment. |
63aa9df0 | 58 | The \fBunsetenv\fP() function returns zero on success, |
fea681da MK |
59 | or \-1 on error, with |
60 | .I errno | |
61 | set to indicate the cause of the error. | |
62 | .SH "ERRORS" | |
63 | .TP | |
64 | .B EINVAL | |
65 | .I name | |
66 | contained an '=' character. | |
67 | .SH "CONFORMING TO" | |
b14d4aa5 | 68 | 4.3BSD |
fea681da | 69 | .SH "NOTES" |
63aa9df0 | 70 | Prior to glibc 2.2.2, \fBunsetenv\fP() was prototyped |
fea681da MK |
71 | as returning \fIvoid\fP; more recent glibc versions follow the |
72 | SUSv3-compliant prototype shown in the SYNOPSIS. | |
73 | .SH BUGS | |
74 | SUSv3 specifies that if | |
75 | .I name | |
76 | contains an '=' character, then | |
77 | .BR setenv () | |
78 | should fail with the error | |
79 | .BR EINVAL ; | |
279d6eea | 80 | however, versions of glibc before 2.3.4 allowed an '=' sign in |
fea681da | 81 | .IR name . |
fea681da MK |
82 | .SH "SEE ALSO" |
83 | .BR clearenv (3), | |
84 | .BR getenv (3), | |
85 | .BR putenv (3), | |
86 | .BR environ (5) |