summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/getenv.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/getenv.3')
-rw-r--r--src/lib/libc/stdlib/getenv.366
1 files changed, 30 insertions, 36 deletions
diff --git a/src/lib/libc/stdlib/getenv.3 b/src/lib/libc/stdlib/getenv.3
index 411eb35da4..b2aa0080d6 100644
--- a/src/lib/libc/stdlib/getenv.3
+++ b/src/lib/libc/stdlib/getenv.3
@@ -1,5 +1,5 @@
1.\" Copyright (c) 1988, 1991 The Regents of the University of California. 1.\" Copyright (c) 1988, 1991, 1993
2.\" All rights reserved. 2.\" The Regents of the University of California. All rights reserved.
3.\" 3.\"
4.\" This code is derived from software contributed to Berkeley by 4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information 5.\" the American National Standards Committee X3, on Information
@@ -33,10 +33,9 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" from: @(#)getenv.3 6.11 (Berkeley) 6/29/91 36.\" $OpenBSD: getenv.3,v 1.7 2000/04/20 13:50:02 aaron Exp $
37.\" $Id: getenv.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $
38.\" 37.\"
39.Dd June 29, 1991 38.Dd December 11, 1993
40.Dt GETENV 3 39.Dt GETENV 3
41.Os 40.Os
42.Sh NAME 41.Sh NAME
@@ -56,59 +55,51 @@
56.Ft void 55.Ft void
57.Fn unsetenv "const char *name" 56.Fn unsetenv "const char *name"
58.Sh DESCRIPTION 57.Sh DESCRIPTION
59These functions set, unset and fetch environment variables from the 58These functions set, unset, and fetch environment variables from the host
60host
61.Em environment list . 59.Em environment list .
62For compatibility with differing environment conventions, 60For compatibility with differing environment conventions, the given arguments
63the given arguments 61.Fa name
64.Ar name
65and 62and
66.Ar value 63.Fa value
67may be appended and prepended, 64may be appended and prepended, respectively, with an equal sign
68respectively,
69with an equal sign
70.Dq Li \&= . 65.Dq Li \&= .
71.Pp 66.Pp
72The 67The
73.Fn getenv 68.Fn getenv
74function obtains the current value of the environment variable, 69function obtains the current value of the environment variable,
75.Ar name . 70.Fa name .
76If the variable 71If the variable
77.Ar name 72.Fa name
78is not in the current environment , 73is not in the current environment, a null pointer is returned.
79a null pointer is returned.
80.Pp 74.Pp
81The 75The
82.Fn setenv 76.Fn setenv
83function inserts or resets the environment variable 77function inserts or resets the environment variable
84.Ar name 78.Fa name
85in the current environment list. 79in the current environment list.
86If the variable 80If the variable
87.Ar name 81.Fa name
88does not exist in the list, 82does not exist in the list, it is inserted with the given
89it is inserted with the given 83.Fa value .
90.Ar value.
91If the variable does exist, the argument 84If the variable does exist, the argument
92.Ar overwrite 85.Fa overwrite
93is tested; if 86is tested; if
94.Ar overwrite is 87.Fa overwrite
95zero, the 88is zero, the variable is not reset, otherwise it is reset to the given
96variable is not reset, otherwise it is reset 89.Fa value .
97to the given
98.Ar value .
99.Pp 90.Pp
100The 91The
101.Fn putenv 92.Fn putenv
102function takes an argument of the form ``name=value'' and is 93function takes an argument of the form
103equivalent to: 94.Ar name Ns No = Ns Ar value
95and is equivalent to:
104.Bd -literal -offset indent 96.Bd -literal -offset indent
105setenv(name, value, 1); 97setenv(name, value, 1);
106.Ed 98.Ed
107.Pp 99.Pp
108The 100The
109.Fn unsetenv 101.Fn unsetenv
110function 102function deletes all instances of the variable name pointed to by
111deletes all instances of the variable name pointed to by
112.Fa name 103.Fa name
113from the list. 104from the list.
114.Sh RETURN VALUES 105.Sh RETURN VALUES
@@ -118,10 +109,13 @@ and
118.Fn putenv 109.Fn putenv
119return zero if successful; otherwise the global variable 110return zero if successful; otherwise the global variable
120.Va errno 111.Va errno
121is set to indicate the error and a 112is set to indicate the error and \-1 is returned.
122\-1 is returned. 113.Pp
114If
115.Fn getenv
116is successful, the string returned should be considered read-only.
123.Sh ERRORS 117.Sh ERRORS
124.Bl -tag -width Er 118.Bl -tag -width [ENOMEM]
125.It Bq Er ENOMEM 119.It Bq Er ENOMEM
126The function 120The function
127.Fn setenv 121.Fn setenv