OSDN Git Service

90f339f28ba06402eb3c8e8232ed66b5f062fff1
[linuxjm/LDP_man-pages.git] / draft / man7 / environ.7
1 .\" Copyright (c) 1993 Michael Haardt (michael@moria.de),
2 .\"   Fri Apr  2 11:32:09 MET DST 1993
3 .\" and Andries Brouwer (aeb@cwi.nl), Fri Feb 14 21:47:50 1997.
4 .\"
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, write to the Free
22 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
23 .\" USA.
24 .\"
25 .\" Modified Sun Jul 25 10:45:30 1993 by Rik Faith (faith@cs.unc.edu)
26 .\" Modified Sun Jul 21 21:25:26 1996 by Andries Brouwer (aeb@cwi.nl)
27 .\" Modified Mon Oct 21 17:47:19 1996 by Eric S. Raymond (esr@thyrsus.com)
28 .\" Modified Wed Aug 27 20:28:58 1997 by Nicolas Lichtmaier (nick@debian.org)
29 .\" Modified Mon Sep 21 00:00:26 1998 by Andries Brouwer (aeb@cwi.nl)
30 .\" Modified Wed Jan 24 06:37:24 2001 by Eric S. Raymond (esr@thyrsus.com)
31 .\" Modified Thu Dec 13 23:53:27 2001 by Martin Schulze <joey@infodrom.org>
32 .\"
33 .\" nakano 注: Nicolas さんの a はオリジナルでは \'a だが,
34 .\" キャラクタを壊すので a に変更した.
35 .\"
36 .\" Japanese Version Copyright (c) 1997 KURODA Masaru all rights reserved.
37 .\" Translated May 27, 1997 by KURODA Masaru <kuro@st.rim.or.jp>
38 .\" Modified Sat 25 Jul 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
39 .\" Modified Sun 6 Dec 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
40 .\" Updated & Modified Sat Aug 21 1999
41 .\"       by NAKANO Takeo <nakano@apm.seikei.ac.jp>
42 .\" Updated & Modified Sat 18 Mar 2000 by NAKANO Takeo
43 .\" Updated Sat Dec 22 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
44 .\" Updated Sat Mar 23 JST 2002 by Kentaro Shirakata <argrath@ub32.org>
45 .\" Updated 2010-04-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.24
46 .\"
47 .\"WORD:        environment             環境
48 .\"WORD:        environment variable    環境変数
49 .\"WORD:        shell variable          シェル変数
50 .\"WORD:        locale                  ロケール
51 .\"WORD:        locale category         ロケールカテゴリ
52 .\"
53 .TH ENVIRON 7 2009-07-25 "Linux" "Linux Programmer's Manual"
54 .\"O .SH NAME
55 .\"O environ \- user environment
56 .SH 名前
57 environ \- ユーザ環境
58 .\"O .SH SYNOPSIS
59 .SH 書式
60 .nf
61 .BI "extern char **" environ ;
62 .br
63 .fi
64 .\"O .SH DESCRIPTION
65 .SH 説明
66 .\"O The variable
67 .\"O .I environ
68 .\"O points to an array of pointers to strings called the "environment".
69 .\"O The last pointer in this array has the value NULL.
70 .\"O (This variable must be declared in the user program,
71 .\"O but is declared in the header file
72 .\"O .I <unistd.h>
73 .\"O in case the header files came from libc4 or libc5, and
74 .\"O in case they came from glibc and
75 .\"O .B _GNU_SOURCE
76 .\"O was defined.)
77 .\"O This array of strings is made available to the process by the
78 .\"O .BR exec (3)
79 .\"O call that started the process.
80 変数
81 .I environ
82 は「環境 (environment)」と呼ばれる文字列へのポインタの配列である。
83 この配列の最後のポインタの値は NULL である。
84 (この変数はユーザープログラムで宣言しなければならない。
85 ただし libc4 や libc5 のヘッダーファイルなら
86 .I <unistd.h>
87 で宣言されているし、これが glibc 由来のものでも
88 .B _GNU_SOURCE
89 が define されていれば宣言済みとなる)。
90 この文字列配列は、
91 プロセスを起動する
92 .BR exec (3)
93 によって、その起動されたプロセスで利用できるようになる。
94
95 .\"O By convention the strings in
96 .\"O .I environ
97 .\"O have the form "\fIname\fP\fB=\fP\fIvalue\fP".
98 .\"O Common examples are:
99 通例では、
100 .I environ
101 の文字列は "\fIname\fP\fB=\fP\fIvalue\fP" という書式をとる。
102 よく用いられる例を以下に示す。
103 .TP
104 .B USER
105 .\"O The name of the logged-in user (used by some BSD-derived programs).
106 ユーザのログイン名 (BSD 起源のプログラムなどによって使用される)。
107 .TP
108 .B LOGNAME
109 .\"O The name of the logged-in user (used by some System-V derived programs).
110 ユーザのログイン名(System V 起源のプログラムなどによって使用される)。
111 .TP
112 .B HOME
113 .\"O A user's login directory, set by
114 .\"O .BR login (1)
115 .\"O from the password file
116 .\"O .BR passwd (5).
117 ユーザのログインディレクトリ。
118 .BR login (1)
119 がパスワードファイル
120 .BR passwd (5)
121 から取得して設定する。
122 .TP
123 .B LANG
124 .\"O The name of a locale to use for locale categories when not overridden
125 .\"O by \fBLC_ALL\fP or more specific environment variables like
126 .\"O \fBLC_COLLATE\fP, \fBLC_CTYPE\fP, \fBLC_MESSAGES\fP, \fBLC_MONETARY\fP,
127 .\"O \fBLC_NUMERIC\fP, \fBLC_TIME\fP, cf.
128 .\"O .BR locale (5).
129 ロケールの各カテゴリで使用されるロケールの名前。\fBLC_ALL\fP や、
130 より狭い範囲を対象とする環境変数
131 .RB ( LC_COLLATE ,
132 .BR LC_CTYPE ,
133 .BR LC_MESSAGES ,
134 .BR LC_MONETARY ,
135 .BR LC_NUMERIC ,
136 .B LC_TIME
137 など)
138 によって上書きされることもある。
139 .BR locale (5)
140 を見よ。
141 .TP
142 .B PATH
143 .\"O The sequence of directory prefixes that
144 .\"O .BR sh (1)
145 .\"O and many other
146 .\"O programs apply in searching for a file known by an incomplete pathname.
147 .\"O The prefixes are separated by \(aq\fB:\fP\(aq.
148 .\"O (Similarly one has \fBCDPATH\fP used by some shells to find the target
149 .\"O of a change directory command, \fBMANPATH\fP used by
150 .\"O .BR man (1)
151 .\"O to
152 .\"O find manual pages, etc.)
153 .BR sh (1)
154 や他のプログラムが、フルパスで与えられなかった実行ファイルを検索するとき、
155 ファイル名に前置されるディレクトリの配列。
156 各ディレクトリは \(aq\fB:\fP\(aq によって区切られる。
157 (同じようなものに、
158 シェルがディレクトリ変更コマンドの変更先を探すために用いる
159 \fBCDPATH\fP や、
160 .BR man (1)
161 がマニュアルページの検索に用いる \fBMANPATH\fP などがある。)
162 .TP
163 .B PWD
164 .\"O The current working directory.
165 .\"O Set by some shells.
166 現在のワーキングディレクトリ。いくつかのシェルが設定する。
167 .TP
168 .B SHELL
169 .\"O The pathname of the user's login shell.
170 ユーザーのログインシェルのパス名。
171 .TP
172 .B TERM
173 .\"O The terminal type for which output is to be prepared.
174 端末の種類。出力はこれにあわせて用意される。
175 .TP
176 .B PAGER
177 .\"O The user's preferred utility to display text files.
178 テキストファイルを表示するユーテリティ。ユーザーが好みのものを設定する。
179 .TP
180 .BR EDITOR / VISUAL
181 .\"O The user's preferred utility to edit text files.
182 テキストファイルを編集するユーテリティ。ユーザーが好みのものを設定する。
183 .\" .TP
184 .\" .B BROWSER
185 .\"O .\" The user's preferred utility to browse URLs. Sequence of colon-separated
186 .\"O .\" browser commands. See http://www.catb.org/~esr/BROWSER/ .
187 .\" URL の閲覧に用いるユーティリティ。ユーザーが好みのものを設定する。
188 .\" コロンで区切ってブラウザコマンドを並べる。
189 .\" http://www.catb.org/~esr/BROWSER/ を見よ。
190 .PP
191 .\"O Further names may be placed in the environment by the \fIexport\fP
192 .\"O command and "name=value" in
193 .\"O .BR sh (1),
194 .\"O or by the \fIsetenv\fP command if you use
195 .\"O .BR csh (1).
196 .\"O Arguments may also be placed in the
197 .\"O environment at the point of an
198 .\"O .BR exec (3).
199 .\"O A C program can manipulate its environment using the functions
200 .\"O .BR getenv (3),
201 .\"O .BR putenv (3),
202 .\"O .BR setenv (3),
203 .\"O and
204 .\"O .BR unsetenv (3).
205 環境に名前を追加する場合には、
206 .BR sh (1)
207 では \fIexport\fP コマンドと "name=value" を使用する。
208 .BR csh (1)
209 では \fIsetenv\fP コマンドを使用する。
210 .BR exec (3)
211 の引数としても環境を設定することができる。
212 C プログラムからは、
213 .BR getenv (3),
214 .BR putenv (3),
215 .BR setenv (3),
216 .BR unsetenv (3)
217 などの関数を用いて環境を扱うことができる。
218
219 .\"O Note that the behavior of many programs and library routines is
220 .\"O influenced by the presence or value of certain environment variables.
221 .\"O A random collection:
222 プログラムやライブラリルーチンの多くは、それぞれ適当な環境変数の存在
223 や値によって、動作に影響を受けることがある。以下、適宜挙げてみよう。
224 .LP
225 .\"O The variables
226 .\"O .BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ", "
227 .\"O .BR LC_ALL ", " LC_MESSAGES ", "
228 .\"O etc. influence locale handling, cf.
229 .\"O .BR locale (5).
230 .BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ", "
231 .BR LC_ALL ", " LC_MESSAGES ", "
232 などの変数。ロケールの扱いに影響する。
233 .BR locale (5)
234 を見よ。
235 .LP
236 .\"O .B TMPDIR
237 .\"O influences the path prefix of names created by
238 .\"O .BR tmpnam (3)
239 .\"O and other routines, the temporary directory used by
240 .\"O .BR sort (1)
241 .\"O and other programs, etc.
242 .B TMPDIR
243
244 .BR tmpnam (3)
245 などのルーチンによって作成されるファイル名に前置されるパスに影響する。また
246 .BR sort (1)
247 の一時ディレクトリに用いられたり、他のプログラムからも利用される。
248 .LP
249 .\"O .BR LD_LIBRARY_PATH ", " LD_PRELOAD
250 .\"O and other LD_* variables influence
251 .\"O the behavior of the dynamic loader/linker.
252 .BR LD_LIBRARY_PATH ", " LD_PRELOAD
253 などの LD_* 変数はダイナミックローダ・リンカの動作に影響する。
254 .LP
255 .\"O .B POSIXLY_CORRECT
256 .\"O makes certain programs and library routines follow
257 .\"O the prescriptions of POSIX.
258 .B POSIXLY_CORRECT
259 が指定されると、ある種のプログラムやライブラリルーチンは
260 POSIX の規定に従うようになる。
261 .LP
262 .\"O The behavior of
263 .\"O .BR malloc (3)
264 .\"O is influenced by
265 .\"O .B MALLOC_*
266 .\"O variables.
267 .BR malloc (3)
268 の動作は
269 .B MALLOC_*
270 変数によって影響される。
271 .LP
272 .\"O The variable
273 .\"O .B HOSTALIASES
274 .\"O gives the name of a file containing aliases
275 .\"O to be used with
276 .\"O .BR gethostbyname (3).
277 .B HOSTALIAS
278 変数は、
279 .BR gethostbyname (3)
280 が用いるエイリアスが書かれているファイル名を与える。
281 .LP
282 .\"O .BR TZ " and " TZDIR
283 .\"O give timezone information used by
284 .\"O .BR tzset (3)
285 .\"O and through that by functions like
286 .\"O .BR ctime (3),
287 .\"O .BR localtime (3),
288 .\"O .BR mktime (3),
289 .\"O .BR strftime (3).
290 .\"O See also
291 .\"O .BR tzselect (8).
292 .BR TZ " と " TZDIR
293
294 .BR tzset (3)
295 および、この関数を使う
296 .BR ctime (3),
297 .BR localtime (3),
298 .BR mktime (3),
299 .BR strftime (3)
300 といった関数で用いられるタイムゾーンの情報を与える。
301 .BR tzselect (8)
302 も参照のこと。
303 .LP
304 .\"O .B TERMCAP
305 .\"O gives information on how to address a given terminal
306 .\"O (or gives the name of a file containing such information).
307 .B TERMCAP
308 は、現在の端末情報の取得先
309 (あるいはそのような情報が書かれているファイル名) を与える。
310 .LP
311 .\"O .BR COLUMNS " and " LINES
312 .\"O tell applications about the window size, possibly overriding the actual size.
313 .BR COLUMNS " と " LINES
314 アプリケーションにウインドウのサイズを伝える。
315 実際のサイズとは違う値を与えることもできる。
316 .LP
317 .\"O .BR PRINTER " or " LPDEST
318 .BR PRINTER " または " LPDEST
319 .\"O may specify the desired printer to use.
320 .\"O See
321 .\"O .BR lpr (1).
322 用いたいプリンタを指定する。
323 .BR lpr (1)
324 を参照のこと。
325 .LP
326 .\"O Etc.
327 などなど...
328 .\"O .SH BUGS
329 .SH バグ
330 .\"O Clearly there is a security risk here.
331 .\"O Many a system command has been
332 .\"O tricked into mischief by a user who specified unusual values for
333 .\"O .BR IFS " or " LD_LIBRARY_PATH .
334 これらの中には、明らかにセキュリティ上の危険が存在する。
335 ユーザーが
336 .BR IFS " や " LD_LIBRARY_PATH
337 に異常な値を与えたことによって、
338 これまで多くのシステムコマンドがだまされて、
339 システムをひどい目にあわせてきた。
340
341 .\"O There is also the risk of name space pollution.
342 .\"O Programs like
343 .\"O .I make
344 .\"O and
345 .\"O .I autoconf
346 .\"O allow overriding of default utility names from the
347 .\"O environment with similarly named variables in all caps.
348 .\"O Thus one uses
349 .\"O .B CC
350 .\"O to select the desired C compiler (and similarly
351 .\"O .BR MAKE ,
352 .\"O .BR AR ,
353 .\"O .BR AS ,
354 .\"O .BR FC ,
355 .\"O .BR LD ,
356 .\"O .BR LEX ,
357 .\"O .BR RM ,
358 .\"O .BR YACC ,
359 .\"O etc.).
360 名前空間が汚染される危険性も存在する。
361 .I make
362
363 .I autoconf
364 のようなプログラムでは、デフォルトのユーティリティを
365 環境にある似たような名前の変数で上書きすることができる
366 (通常はすべて大文字の変数を用いる)。
367 すなわち、利用したい C コンパイラは
368 .B CC
369 で選択できる。また同様に
370 .BR MAKE ,
371 .BR AR ,
372 .BR AS ,
373 .BR FC ,
374 .BR LD ,
375 .BR LEX ,
376 .BR RM ,
377 .B YACC
378 なども用いることができる。
379 .\"O However, in some traditional uses such an environment variable
380 .\"O gives options for the program instead of a pathname.
381 .\"O Thus, one has
382 .\"O .BR MORE ,
383 .\"O .BR LESS ,
384 .\"O and
385 .\"O .BR GZIP .
386 .\"O Such usage is considered mistaken, and to be avoided in new
387 .\"O programs.
388 .\"O The authors of
389 .\"O .I gzip
390 .\"O should consider renaming their option to
391 .\"O .BR GZIP_OPT .
392 ところが一方では、このような変数を
393 (パス名ではなく)
394 プログラムに対するオプションとして扱うような流儀も存在してきた。
395 例えば
396 .BR MORE ,
397 .BR LESS ,
398 .B GZIP
399 などがそうである。
400 このような利用法は間違っていると考えるべきで、
401 新しいプログラムでは避けるべきである。
402 .I gzip
403 の作者たちは、オプションを与える環境変数を
404 .B GZIP_OPT
405 に改名することを考えるほうがよい。
406 .\"O .SH "SEE ALSO"
407 .SH 関連項目
408 .BR bash (1),
409 .BR csh (1),
410 .BR login (1),
411 .BR sh (1),
412 .BR tcsh (1),
413 .BR execve (2),
414 .BR clearenv (3),
415 .BR exec (3),
416 .BR getenv (3),
417 .BR putenv (3),
418 .BR setenv (3),
419 .BR unsetenv (3),
420 .BR locale (5)