1 .\" Copyright (c) 1988, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the American National Standards Committee X3, on Information
6 .\" Processing Systems.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)getenv.3 8.2 (Berkeley) 12/11/93
44 .Nd environment variable functions
52 .Fn getenv "const char *name"
54 .Fn secure_getenv "const char *name"
56 .Fn setenv "const char *name" "const char *value" "int overwrite"
58 .Fn putenv "char *string"
60 .Fn unsetenv "const char *name"
62 These functions set, unset and fetch environment variables from the
64 .Em environment list .
68 function clears all environment variables.
69 New variables can be added using
76 function obtains the current value of the environment variable,
78 The application should not modify the string pointed
87 when the environment cannot be trusted, otherwise it acts like
89 The environment currently is not trusted when
91 returns a non-zero value, but other conditions may be added
96 function inserts or resets the environment variable
98 in the current environment list.
101 does not exist in the list,
102 it is inserted with the given
104 If the variable does exist, the argument
109 variable is not reset, otherwise it is reset
115 function takes an argument of the form ``name=value'' and
116 puts it directly into the current environment,
117 so altering the argument shall change the environment.
120 does not exist in the list,
121 it is inserted with the given
125 does exist, it is reset to the given
131 deletes all instances of the variable name pointed to by
135 If corruption (e.g., a name without a value) is detected while making a copy of
136 environ for internal usage, then
141 will output a warning to stderr about the issue, drop the corrupt entry and
142 complete the task without error.
146 function returns the value of the environment variable as a
151 is not in the current environment,
159 if the process is in "secure execution," otherwise it will call
162 .Rv -std clearenv setenv putenv unsetenv
175 pointer, points to an empty string, or points to a string containing an
191 is the first character in
193 This does not follow the
202 failed because they were unable to allocate memory for the environment.
219 functions conforms to
223 function is expected to be glibc-compatible.
241 and insert it into the environment using
243 This was changed to use
245 as the memory location of the ``name=value'' pair to follow the
253 functions were added in
258 that assign a larger-sized
260 than any previous value to the same
262 will result in a memory leak.
265 semantics for this function
266 (namely, that the contents of
268 are copied and that old values remain accessible indefinitely) make this
270 Future versions may eliminate one or both of these
271 semantic guarantees in order to fix the bug.