OSDN Git Service

(split) LDP v3.30, v3.31 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man3 / setenv.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2004, 2007 Michael kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" References consulted:
25 .\"     Linux libc source code
26 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\"     386BSD man pages
28 .\" Modified Sat Jul 24 18:20:58 1993 by Rik Faith (faith@cs.unc.edu)
29 .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl)
30 .\" Modified 9 Jun 2004, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Changed unsetenv() prototype; added EINVAL error
32 .\"     Noted nonstandard behavior of setenv() if name contains '='
33 .\" 2005-08-12, mtk, glibc 2.3.4 fixed the "name contains '='" bug
34 .\"
35 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
36 .\"     all rights reserved.
37 .\" Translated 1997-12-19, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
38 .\" Updated & Modified 2005-02-17, Yuichi SATO <ysato444@yahoo.co.jp>
39 .\" Updated & Modified 2005-10-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05
41 .\" Updated 2010-04-10, Akihiro MOTOKI, LDP v3.24
42 .\"
43 .TH SETENV 3  2009-09-20 "GNU" "Linux Programmer's Manual"
44 .\"O .SH NAME
45 .SH Ì¾Á°
46 .\"O setenv \- change or add an environment variable
47 setenv \- ´Ä¶­ÊÑ¿ô¤òÊѹ¹¤Þ¤¿¤ÏÄɲ乤ë
48 .\"O .SH SYNOPSIS
49 .SH ½ñ¼°
50 .nf
51 .B #include <stdlib.h>
52 .sp
53 .BI "int setenv(const char *" name ", const char *" value ", int " overwrite );
54 .sp
55 .BI "int unsetenv(const char *" name );
56 .fi
57 .sp
58 .in -4n
59 .\"O Feature Test Macro Requirements for glibc (see
60 .\"O .BR feature_test_macros (7)):
61 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
62 .RB ( feature_test_macros (7)
63 »²¾È):
64 .in
65 .sp
66 .ad l
67 .BR setenv (),
68 .BR unsetenv ():
69 .RS 4
70 _BSD_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
71 .RE
72 .ad b
73 .\"O .SH DESCRIPTION
74 .SH ÀâÌÀ
75 .\"O The
76 .\"O .BR setenv ()
77 .\"O function adds the variable \fIname\fP to the
78 .\"O environment with the value \fIvalue\fP, if \fIname\fP does not
79 .\"O already exist.
80 .\"O If \fIname\fP does exist in the environment, then
81 .\"O its value is changed to \fIvalue\fP if \fIoverwrite\fP is nonzero;
82 .\"O if \fIoverwrite\fP is zero, then the value of \fIname\fP is not
83 .\"O changed.
84 .BR setenv ()
85 ´Ø¿ô¤Ï¡¢\fIname\fP ¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç
86 ´Ä¶­ÊÑ¿ô \fIname\fP ¤ËÃÍ \fIvalue\fP ¤òÀßÄꤷ¡¢´Ä¶­¤ËÄɲ乤롣
87 \fIname\fP ¤¬´Ä¶­¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢\fIoverwrite\fP ¤¬ 0 °Ê³°¤Ê¤é¤Ð
88 ¤½¤ÎÃͤò \fIvalue\fP ¤ËÊѹ¹¤·¡¢\fIoverwrite\fP ¤¬ 0 ¤Ê¤é¤Ð
89 \fIname\fP ¤ÎÃͤòÊѹ¹¤·¤Ê¤¤¡£
90 .\"O This function makes copies of the strings pointed to by
91 .\"O .I name
92 .\"O and
93 .\"O .I value
94 .\"O (by contrast with
95 .\"O .BR putenv (3)).
96 ¤³¤Î´Ø¿ô¤Ï¡¢
97 .RB ( putenv (3)
98 ¤È°ã¤¤)
99 .I name
100 ¤È
101 .I value
102 ¤Ë¤è¤ê»²¾È¤µ¤ì¤ëʸ»úÎó¤Î¥³¥Ô¡¼¤ò¹Ô¤¦¡£
103 .PP
104 .\"O The
105 .\"O .BR unsetenv ()
106 .\"O function deletes the variable \fIname\fP from
107 .\"O the environment.
108 .BR unsetenv ()
109 ´Ø¿ô¤Ï¡¢ÊÑ¿ô \fIname\fP ¤ò´Ä¶­¤«¤éºï½ü¤¹¤ë¡£
110 .\"O If
111 .\"O .I name
112 .\"O does not exist in the environment,
113 .\"O then the function succeeds, and the environment is unchanged.
114 .I name
115 ¤¬´Ä¶­¤Ë¤Ê¤¤¾ì¹ç¡¢¤³¤Î´Ø¿ô¤ÏÀ®¸ù¤·¡¢´Ä¶­¤ÏÊѹ¹¤µ¤ì¤Ê¤¤¡£
116 .\"O .SH "RETURN VALUE"
117 .SH ÊÖ¤êÃÍ
118 .\"O The
119 .\"O .BR setenv ()
120 .\"O function returns zero on success,
121 .\"O or \-1 on error, with
122 .\"O .I errno
123 .\"O set to indicate the cause of the error.
124 .BR setenv ()
125 ´Ø¿ô¤Ï¡¢À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
126 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
127 .I errno
128 ¤Ë¥¨¥é¡¼¤Î¸¶°ø¤ò¼¨¤¹Ãͤ¬¥»¥Ã¥È¤µ¤ì¤ë¡£
129
130 .\"O The
131 .\"O .BR unsetenv ()
132 .\"O function returns zero on success,
133 .\"O or \-1 on error, with
134 .\"O .I errno
135 .\"O set to indicate the cause of the error.
136 .BR unsetenv ()
137 ´Ø¿ô¤Ï¡¢À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
138 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
139 .I errno
140 ¤òÀßÄꤷ¤Æ¥¨¥é¡¼¤Î¸¶°ø¤ò¼¨¤¹¡£
141 .\"O .SH "ERRORS"
142 .SH ¥¨¥é¡¼
143 .TP
144 .B EINVAL
145 .\"O .I name
146 .\"O is NULL, points to a string of length 0,
147 .\"O or contains an \(aq=\(aq character.
148 .I name
149 ¤¬ NULL ¤Ç¤¢¤ë¤«¡¢Ä¹¤µ¤¬ 0 ¤Îʸ»úÎó¤ò»Ø¤·¤Æ¤¤¤ë¤«¡¢
150 \(aq=\(aq Ê¸»ú¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¡£
151 .TP
152 .B ENOMEM
153 .\"O Insufficient memory to add a new variable to the environment.
154 ´Ä¶­¤Ë¿·¤·¤¤ÊÑ¿ô¤òÄɲ乤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
155 .\"O .SH "CONFORMING TO"
156 .SH ½àµò
157 4.3BSD, POSIX.1-2001.
158 .\"O .SH "NOTES"
159 .SH Ãí°Õ
160 .\"O POSIX.1-2001 does not require
161 .\"O .BR setenv ()
162 .\"O or
163 .\"O .BR unsetenv ()
164 .\"O to be reentrant.
165 POSIX.1-2001 ¤Ï¡¢
166 .BR setenv ()
167 ¤ä
168 .BR unsetenv ()
169 ¤¬¥ê¥¨¥ó¥È¥é¥ó¥È (ºÆÆþ²Äǽ) ¤Ç¤¢¤ë¤³¤È¤òÍ׵ᤷ¤Æ¤¤¤Ê¤¤¡£
170
171 .\"O Prior to glibc 2.2.2,
172 .\"O .BR unsetenv ()
173 .\"O was prototyped
174 .\"O as returning \fIvoid\fP; more recent glibc versions follow the
175 .\"O POSIX.1-2001-compliant prototype shown in the SYNOPSIS.
176 glibc 2.2.2 °ÊÁ°¤Ç¤Ï¡¢
177 .BR unsetenv ()
178 ¤Ï
179 ÊÖ¤êÃͤ¬ \fIvoid\fP ¤Î¥×¥í¥È¥¿¥¤¥×¤Ç¤¢¤Ã¤¿¡£
180 ¤â¤Ã¤ÈºÇ¶á¤Î glibc ÈǤϡ¢¡Ö½ñ¼°¡×¥»¥¯¥·¥ç¥ó¤Ç¼¨¤·¤Æ¤¤¤ë¤è¤¦¤Ë
181 POSIX.1-2001 ¸ß´¹¤Î¥×¥í¥È¥¿¥¤¥×¤Ç¤¢¤ë¡£
182 .\"O .SH BUGS
183 .SH ¥Ð¥°
184 .\"O POSIX.1-2001 specifies that if
185 .\"O .I name
186 .\"O contains an \(aq=\(aq character, then
187 .\"O .BR setenv ()
188 .\"O should fail with the error
189 .\"O .BR EINVAL ;
190 POSIX.1-2001 ¤Ç¤Ï
191 .RI ¡Ö name
192 ¤Ë \(aq=\(aq Ê¸»ú¤¬´Þ¤Þ¤ì¤ë¾ì¹ç¡¢
193 .BR setenv ()
194 ¤Ï¥¨¥é¡¼
195 .B EINVAL
196 ¤Ç¼ºÇÔ¤¹¤Ù¤­¤Ç¤¢¤ë¡×¤È½Ò¤Ù¤é¤ì¤Æ¤¤¤ë¡£
197 .\"O however, versions of glibc before 2.3.4 allowed an \(aq=\(aq sign in
198 .\"O .IR name .
199 ¤·¤«¤· 2.3.4 ¤è¤êÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤Î glibc ¤Ç¤Ï¡¢
200 .I name
201 ¤Ë \(aq=\(aq Ê¸»ú¤¬´Þ¤Þ¤ì¤ë¤Î¤òµö¤·¤Æ¤¤¤ë¡£
202 .\"O .SH "SEE ALSO"
203 .SH ´ØÏ¢¹àÌÜ
204 .BR clearenv (3),
205 .BR getenv (3),
206 .BR putenv (3),
207 .BR environ (7)