.\" Copyright (c) 1993 Michael Haardt (michael@moria.de), .\" Fri Apr 2 11:32:09 MET DST 1993 .\" and Andries Brouwer (aeb@cwi.nl), Fri Feb 14 21:47:50 1997. .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" %%%LICENSE_END .\" .\" Modified Sun Jul 25 10:45:30 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Sun Jul 21 21:25:26 1996 by Andries Brouwer (aeb@cwi.nl) .\" Modified Mon Oct 21 17:47:19 1996 by Eric S. Raymond (esr@thyrsus.com) .\" Modified Wed Aug 27 20:28:58 1997 by Nicolás Lichtmaier (nick@debian.org) .\" Modified Mon Sep 21 00:00:26 1998 by Andries Brouwer (aeb@cwi.nl) .\" Modified Wed Jan 24 06:37:24 2001 by Eric S. Raymond (esr@thyrsus.com) .\" Modified Thu Dec 13 23:53:27 2001 by Martin Schulze .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 KURODA Masaru all rights reserved. .\" Translated May 27, 1997 by KURODA Masaru .\" Modified Sat 25 Jul 1998 by NAKANO Takeo .\" Modified Sun 6 Dec 1998 by NAKANO Takeo .\" Updated & Modified Sat Aug 21 1999 .\" by NAKANO Takeo .\" Updated & Modified Sat 18 Mar 2000 by NAKANO Takeo .\" Updated Sat Dec 22 JST 2001 by Kentaro Shirakata .\" Updated Sat Mar 23 JST 2002 by Kentaro Shirakata .\" Updated 2010-04-11, Akihiro MOTOKI , LDP v3.24 .\" .TH ENVIRON 7 " 2020\-08\-13" Linux "Linux Programmer's Manual" .SH 名前 environ \- ユーザー環境 .SH 書式 .nf \fBextern char **\fP\fIenviron\fP\fB;\fP .fi .SH 説明 The variable \fIenviron\fP points to an array of pointers to strings called the "environment". The last pointer in this array has the value NULL. (This variable must be declared in the user program, but is declared in the header file \fI\fP if the \fB_GNU_SOURCE\fP feature test macro is defined.) This array of strings is made available to the process by the \fBexec\fP(3) call that started the process. When a child process is created via \fBfork\fP(2), it inherits a \fIcopy\fP of its parent's environment. .PP 通例では、 \fIenviron\fP の文字列は "\fIname\fP\fB=\fP\fIvalue\fP" という書式をとる。 よく用いられる例を以下に示す。 .TP \fBUSER\fP ユーザーのログイン名 (BSD 起源のプログラムなどによって使用される)。 .TP \fBLOGNAME\fP ユーザーのログイン名(System V 起源のプログラムなどによって使用される)。 .TP \fBHOME\fP ユーザーのログインディレクトリ。 \fBlogin\fP(1) がパスワードファイル \fBpasswd\fP(5) から取得して設定する。 .TP \fBLANG\fP ロケールの各カテゴリーで使用されるロケールの名前。\fBLC_ALL\fP や、 より狭い範囲を対象とする環境変数 (\fBLC_COLLATE\fP, \fBLC_CTYPE\fP, \fBLC_MESSAGES\fP, \fBLC_MONETARY\fP, \fBLC_NUMERIC\fP, \fBLC_TIME\fP など) によって上書きされることもある (\fBLC_*\fP 環境変数のさらなる詳細は \fBlocale\fP(7) 参照)。 .TP \fBPATH\fP \fBsh\fP(1) や他のプログラムが、フルパスで与えられなかった実行ファイルを検索するとき、 ファイル名に前置されるディレクトリの配列。 各ディレクトリは \(aq\fB:\fP\(aq によって区切られる。 (同じようなものに、 シェルがディレクトリ変更コマンドの変更先を探すために用いる \fBCDPATH\fP や、 \fBman\fP(1) がマニュアルページの検索に用いる \fBMANPATH\fP などがある。) .TP \fBPWD\fP 現在のワーキングディレクトリ。いくつかのシェルが設定する。 .TP \fBSHELL\fP ユーザーのログインシェルのパス名。 .TP \fBTERM\fP 端末の種類。出力はこれにあわせて用意される。 .TP \fBPAGER\fP テキストファイルを表示するユーテリティ。ユーザーが好みのものを設定する。 .TP \fBEDITOR\fP/\fBVISUAL\fP .\" .TP .\" .B BROWSER .\" The user's preferred utility to browse URLs. Sequence of colon-separated .\" browser commands. See http://www.catb.org/\(tiesr/BROWSER/ . テキストファイルを編集するユーテリティ。ユーザーが好みのものを設定する。 .PP Names may be placed in the shell's environment by the \fIexport\fP command in \fBsh\fP(1), or by the \fIsetenv\fP command if you use \fBcsh\fP(1). .PP The initial environment of the shell is populated in various ways, such as definitions from \fI/etc/environment\fP that are processed by \fBpam_env\fP(8) for all users at login time (on systems that employ \fBpam\fP(8)). In addition, various shell initialization scripts, such as the system\-wide \fI/etc/profile\fP script and per\-user initializations script may include commands that add variables to the shell's environment; see the manual page of your preferred shell for details. .PP Bourne\-style shells support the syntax .PP NAME=value command .PP to create an environment variable definition only in the scope of the process that executes \fIcommand\fP. Multiple variable definitions, separated by white space, may precede \fIcommand\fP. .PP \fBexec\fP(3) の引数としても環境を設定することができる。 C プログラムからは、 \fBgetenv\fP(3), \fBputenv\fP(3), \fBsetenv\fP(3), \fBunsetenv\fP(3) などの関数を用いて環境を扱うことができる。 .PP Note that the behavior of many programs and library routines is influenced by the presence or value of certain environment variables. Examples include the following: .IP * 3 \fBLANG\fP, \fBLANGUAGE\fP, \fBNLSPATH\fP, \fBLOCPATH\fP, \fBLC_ALL\fP, \fBLC_MESSAGES\fP, などの変数は、ロケールの扱いに影響する。 \fBcatopen\fP(3), \fBgettext\fP(3), \fBlocale\fP(5) を参照。 .IP * \fBTMPDIR\fP は、 \fBtempnam\fP(3) などのルーチンによって作成されるファイル名や \fBsort\fP(1) や他のプログラムが使用する一時ディレクトリに前置されるパスに影響する。 .IP * \fBLD_LIBRARY_PATH\fP, \fBLD_PRELOAD\fP などの \fBLD_*\fP 変数はダイナミックローダーリンカーの動作に影響する。 .IP * \fBPOSIXLY_CORRECT\fP が指定されると、ある種のプログラムやライブラリルーチンは POSIX の規定に従うようになる。 .IP * \fBmalloc\fP(3) の動作は \fBMALLOC_*\fP 変数によって影響される。 .IP * \fBHOSTALIAS\fP 変数は、 \fBgethostbyname\fP(3) が用いるエイリアスが書かれているファイル名を与える。 .IP * \fBTZ\fP と \fBTZDIR\fP は \fBtzset\fP(3) および、この関数を使う \fBctime\fP(3), \fBlocaltime\fP(3), \fBmktime\fP(3), \fBstrftime\fP(3) といった関数で用いられるタイムゾーンの情報を与える。 \fBtzselect\fP(8) も参照のこと。 .IP * \fBTERMCAP\fP は、現在の端末情報の取得先 (あるいはそのような情報が書かれているファイル名) を与える。 .IP * \fBCOLUMNS\fP と \fBLINES\fP アプリケーションにウインドウのサイズを伝える。 実際のサイズとは違う値を与えることもできる。 .IP * \fBPRINTER\fP または \fBLPDEST\fP 用いたいプリンタを指定する。 \fBlpr\fP(1) を参照のこと。 .SH 注意 The \fBprctl\fP(2) \fBPR_SET_MM_ENV_START\fP and \fBPR_SET_MM_ENV_END\fP operations can be used to control the location of the process's environment. .SH バグ これらの中には、明らかにセキュリティ上の危険が存在する。 ユーザーが \fBIFS\fP や \fBLD_LIBRARY_PATH\fP に異常な値を与えたことによって、 これまで多くのシステムコマンドがだまされて、 システムをひどい目にあわせてきた。 .PP 名前空間が汚染される危険性も存在する。 \fImake\fP や \fIautoconf\fP のようなプログラムでは、デフォルトのユーティリティを 環境にある似たような名前の変数で上書きすることができる (通常はすべて大文字の変数を用いる)。 すなわち、利用したい C コンパイラは \fBCC\fP で選択できる。また同様に \fBMAKE\fP, \fBAR\fP, \fBAS\fP, \fBFC\fP, \fBLD\fP, \fBLEX\fP, \fBRM\fP, \fBYACC\fP なども用いることができる。 ところが一方では、このような変数を (パス名ではなく) プログラムに対するオプションとして扱うような流儀も存在してきた。 例えば \fBMORE\fP, \fBLESS\fP, \fBGZIP\fP などがそうである。 このような利用法は間違っていると考えるべきで、 新しいプログラムでは避けるべきである。 \fIgzip\fP の作者たちは、オプションを与える環境変数を \fBGZIP_OPT\fP に改名することを考えるほうがよい。 .SH 関連項目 \fBbash\fP(1), \fBcsh\fP(1), \fBenv\fP(1), \fBlogin\fP(1), \fBprintenv\fP(1), \fBsh\fP(1), \fBtcsh\fP(1), \fBexecve\fP(2), \fBclearenv\fP(3), \fBexec\fP(3), \fBgetenv\fP(3), \fBputenv\fP(3), \fBsetenv\fP(3), \fBunsetenv\fP(3), \fBlocale\fP(7), \fBld.so\fP(8), \fBpam_env\fP(8) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。