.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" and Copyright (C) 2004, 2007 Michael kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:20:58 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl) .\" Modified 9 Jun 2004, Michael Kerrisk .\" Changed unsetenv() prototype; added EINVAL error .\" Noted nonstandard behavior of setenv() if name contains '=' .\" 2005-08-12, mtk, glibc 2.3.4 fixed the "name contains '='" bug .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-19, HIROFUMI Nishizuka .\" Updated & Modified 2005-02-17, Yuichi SATO .\" Updated & Modified 2005-10-02, Akihiro MOTOKI .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05 .\" Updated 2010-04-10, Akihiro MOTOKI, LDP v3.24 .\" .TH SETENV 3 2013\-10\-11 GNU "Linux Programmer's Manual" .SH 名前 setenv \- 環境変数を変更または追加する .SH 書式 .nf \fB#include \fP .sp \fBint setenv(const char *\fP\fIname\fP\fB, const char *\fP\fIvalue\fP\fB, int \fP\fIoverwrite\fP\fB);\fP .sp \fBint unsetenv(const char *\fP\fIname\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp .ad l \fBsetenv\fP(), \fBunsetenv\fP(): .RS 4 _BSD_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600 .RE .ad b .SH 説明 \fBsetenv\fP() 関数は、\fIname\fP が存在しない場合 環境変数 \fIname\fP に値 \fIvalue\fP を設定し、環境に追加する。 \fIname\fP が環境に存在する場合、\fIoverwrite\fP が 0 以外ならば その値を \fIvalue\fP に変更し、\fIoverwrite\fP が 0 ならば \fIname\fP の値を変更しない (\fBsetenv\fP() は成功のステータスを返す)。 この関数は、 (\fBputenv\fP(3) と違い) \fIname\fP と \fIvalue\fP により参照される文字列のコピーを行う。 .PP \fBunsetenv\fP() 関数は、変数 \fIname\fP を環境から削除する。 \fIname\fP が環境にない場合、この関数は成功し、環境は変更されない。 .SH 返り値 \fBsetenv\fP() 関数は、成功すると 0 を返す。 エラーの場合、\-1 を返し、 \fIerrno\fP にエラーの原因を示す値がセットされる。 \fBunsetenv\fP() 関数は、成功すると 0 を返す。 エラーの場合は \-1 を返し、 \fIerrno\fP を設定してエラーの原因を示す。 .SH エラー .TP \fBEINVAL\fP \fIname\fP が NULL であるか、長さが 0 の文字列を指しているか、 \(aq=\(aq 文字が含まれている。 .TP \fBENOMEM\fP 環境に新しい変数を追加するのに十分なメモリーがない。 .SH 準拠 4.3BSD, POSIX.1\-2001. .SH 注意 POSIX.1\-2001 は、 \fBsetenv\fP() や \fBunsetenv\fP() がリエントラント (再入可能) であることを要求していない。 glibc 2.2.2 以前では、 \fBunsetenv\fP() は 返り値が \fIvoid\fP のプロトタイプであった。 もっと最近の glibc 版は、「書式」セクションで示しているように POSIX.1\-2001 互換のプロトタイプである。 .SH バグ POSIX.1\-2001 では 「\fIname\fP に \(aq=\(aq 文字が含まれる場合、 \fBsetenv\fP() はエラー \fBEINVAL\fP で失敗すべきである」と述べられている。 しかし 2.3.4 より前のバージョンの glibc では、 \fIname\fP に \(aq=\(aq 文字が含まれるのを許している。 .SH 関連項目 \fBclearenv\fP(3), \fBgetenv\fP(3), \fBputenv\fP(3), \fBenviron\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。