1 .\" $NetBSD: getenv.3,v 1.25 2010/10/26 22:34:33 wiz Exp $
3 .\" Copyright (c) 1988, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" the American National Standards Committee X3, on Information
8 .\" Processing Systems.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" from: @(#)getenv.3 8.2 (Berkeley) 12/11/93
45 .Nd environment variable functions
51 .Fn getenv "const char *name"
53 .Fn getenv_r "const char *name" "char *buf" "size_t len"
55 .Fn setenv "const char *name" "const char *value" "int overwrite"
57 .Fn putenv "char *string"
59 .Fn unsetenv "const char *name"
61 These functions set, unset and fetch environment variables from the
63 .Em environment list .
64 For compatibility with differing environment conventions,
71 may be appended with an equal sign
76 function obtains the current value of the environment variable
80 is not in the current environment, a
86 function obtains the current value of the environment variable
92 is not in the current environment, or the string length of the value of
96 characters, then \-1 is returned and
98 is set to indicate the error.
102 function inserts or resets the environment variable
104 in the current environment list.
107 does not exist in the list,
108 it is inserted with the given
110 If the variable does exist, the argument
115 variable is not reset, otherwise it is reset
121 function takes an argument of the form
123 and it will set the environment variable
127 by altering an existing entry, or creating a new one if an existing
129 The actual string argument passed to
131 will become part of the environment.
132 If one changes the string, the environment will also change.
137 deletes all instances of the variable name pointed to by
147 return zero if successful; otherwise the global variable
149 is set to indicate the error and a
154 is successful, the string returned should be considered read-only.
164 is a null pointer, points to an empty string, or points to a string
177 is a null pointer, or points to a string that either starts with a
179 character or does not contain one at all.
185 failed because they were unable to allocate memory for the environment.
190 can return the following errors:
195 was not found in the environment.
197 The value of the named variable is too long to fit in the supplied buffer.