1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2004, 2007 Michael kerrisk <mtk.manpages@gmail.com>
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" References consulted:
25 .\" Linux libc source code
26 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
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
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
43 .TH SETENV 3 2009-09-20 "GNU" "Linux Programmer's Manual"
46 .\"O setenv \- change or add an environment variable
47 setenv \- 環境変数を変更または追加する
51 .B #include <stdlib.h>
53 .BI "int setenv(const char *" name ", const char *" value ", int " overwrite );
55 .BI "int unsetenv(const char *" name );
59 .\"O Feature Test Macro Requirements for glibc (see
60 .\"O .BR feature_test_macros (7)):
62 .RB ( feature_test_macros (7)
70 _BSD_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
77 .\"O function adds the variable \fIname\fP to the
78 .\"O environment with the value \fIvalue\fP, if \fIname\fP does not
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
85 関数は、\fIname\fP が存在しない場合
86 環境変数 \fIname\fP に値 \fIvalue\fP を設定し、環境に追加する。
87 \fIname\fP が環境に存在する場合、\fIoverwrite\fP が 0 以外ならば
88 その値を \fIvalue\fP に変更し、\fIoverwrite\fP が 0 ならば
90 .\"O This function makes copies of the strings pointed to by
94 .\"O (by contrast with
106 .\"O function deletes the variable \fIname\fP from
107 .\"O the environment.
109 関数は、変数 \fIname\fP を環境から削除する。
112 .\"O does not exist in the environment,
113 .\"O then the function succeeds, and the environment is unchanged.
115 が環境にない場合、この関数は成功し、環境は変更されない。
116 .\"O .SH "RETURN VALUE"
120 .\"O function returns zero on success,
121 .\"O or \-1 on error, with
123 .\"O set to indicate the cause of the error.
132 .\"O function returns zero on success,
133 .\"O or \-1 on error, with
135 .\"O set to indicate the cause of the error.
146 .\"O is NULL, points to a string of length 0,
147 .\"O or contains an \(aq=\(aq character.
149 が NULL であるか、長さが 0 の文字列を指しているか、
153 .\"O Insufficient memory to add a new variable to the environment.
154 環境に新しい変数を追加するのに十分なメモリがない。
155 .\"O .SH "CONFORMING TO"
157 4.3BSD, POSIX.1-2001.
160 .\"O POSIX.1-2001 does not require
164 .\"O to be reentrant.
169 がリエントラント (再入可能) であることを要求していない。
171 .\"O Prior to glibc 2.2.2,
174 .\"O as returning \fIvoid\fP; more recent glibc versions follow the
175 .\"O POSIX.1-2001-compliant prototype shown in the SYNOPSIS.
179 返り値が \fIvoid\fP のプロトタイプであった。
180 もっと最近の glibc 版は、「書式」セクションで示しているように
181 POSIX.1-2001 互換のプロトタイプである。
184 .\"O POSIX.1-2001 specifies that if
186 .\"O contains an \(aq=\(aq character, then
188 .\"O should fail with the error
192 に \(aq=\(aq 文字が含まれる場合、
197 .\"O however, versions of glibc before 2.3.4 allowed an \(aq=\(aq sign in
199 しかし 2.3.4 より前のバージョンの glibc では、
201 に \(aq=\(aq 文字が含まれるのを許している。