OSDN Git Service

(split) LDP man-pages の original/ を v3.30 に更新。
[linuxjm/LDP_man-pages.git] / original / 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 Nicolás 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 .TH ENVIRON 7 2009-07-25 "Linux" "Linux Programmer's Manual"
34 .SH NAME
35 environ \- user environment
36 .SH SYNOPSIS
37 .nf
38 .BI "extern char **" environ ;
39 .br
40 .fi
41 .SH DESCRIPTION
42 The variable
43 .I environ
44 points to an array of pointers to strings called the "environment".
45 The last pointer in this array has the value NULL.
46 (This variable must be declared in the user program,
47 but is declared in the header file
48 .I <unistd.h>
49 in case the header files came from libc4 or libc5, and
50 in case they came from glibc and
51 .B _GNU_SOURCE
52 was defined.)
53 This array of strings is made available to the process by the
54 .BR exec (3)
55 call that started the process.
56
57 By convention the strings in
58 .I environ
59 have the form "\fIname\fP\fB=\fP\fIvalue\fP".
60 Common examples are:
61 .TP
62 .B USER
63 The name of the logged-in user (used by some BSD-derived programs).
64 .TP
65 .B LOGNAME
66 The name of the logged-in user (used by some System-V derived programs).
67 .TP
68 .B HOME
69 A user's login directory, set by
70 .BR login (1)
71 from the password file
72 .BR passwd (5).
73 .TP
74 .B LANG
75 The name of a locale to use for locale categories when not overridden
76 by \fBLC_ALL\fP or more specific environment variables like
77 \fBLC_COLLATE\fP, \fBLC_CTYPE\fP, \fBLC_MESSAGES\fP, \fBLC_MONETARY\fP,
78 \fBLC_NUMERIC\fP, \fBLC_TIME\fP, cf.
79 .BR locale (5).
80 .TP
81 .B PATH
82 The sequence of directory prefixes that
83 .BR sh (1)
84 and many other
85 programs apply in searching for a file known by an incomplete pathname.
86 The prefixes are separated by \(aq\fB:\fP\(aq.
87 (Similarly one has \fBCDPATH\fP used by some shells to find the target
88 of a change directory command, \fBMANPATH\fP used by
89 .BR man (1)
90 to
91 find manual pages, etc.)
92 .TP
93 .B PWD
94 The current working directory.
95 Set by some shells.
96 .TP
97 .B SHELL
98 The pathname of the user's login shell.
99 .TP
100 .B TERM
101 The terminal type for which output is to be prepared.
102 .TP
103 .B PAGER
104 The user's preferred utility to display text files.
105 .TP
106 .BR EDITOR / VISUAL
107 The user's preferred utility to edit text files.
108 .\" .TP
109 .\" .B BROWSER
110 .\" The user's preferred utility to browse URLs. Sequence of colon-separated
111 .\" browser commands. See http://www.catb.org/~esr/BROWSER/ .
112 .PP
113 Further names may be placed in the environment by the \fIexport\fP
114 command and "name=value" in
115 .BR sh (1),
116 or by the \fIsetenv\fP command if you use
117 .BR csh (1).
118 Arguments may also be placed in the
119 environment at the point of an
120 .BR exec (3).
121 A C program can manipulate its environment using the functions
122 .BR getenv (3),
123 .BR putenv (3),
124 .BR setenv (3),
125 and
126 .BR unsetenv (3).
127
128 Note that the behavior of many programs and library routines is
129 influenced by the presence or value of certain environment variables.
130 A random collection:
131 .LP
132 The variables
133 .BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ", "
134 .BR LC_ALL ", " LC_MESSAGES ", "
135 etc. influence locale handling, cf.
136 .BR locale (5).
137 .LP
138 .B TMPDIR
139 influences the path prefix of names created by
140 .BR tmpnam (3)
141 and other routines, the temporary directory used by
142 .BR sort (1)
143 and other programs, etc.
144 .LP
145 .BR LD_LIBRARY_PATH ", " LD_PRELOAD
146 and other LD_* variables influence
147 the behavior of the dynamic loader/linker.
148 .LP
149 .B POSIXLY_CORRECT
150 makes certain programs and library routines follow
151 the prescriptions of POSIX.
152 .LP
153 The behavior of
154 .BR malloc (3)
155 is influenced by
156 .B MALLOC_*
157 variables.
158 .LP
159 The variable
160 .B HOSTALIASES
161 gives the name of a file containing aliases
162 to be used with
163 .BR gethostbyname (3).
164 .LP
165 .BR TZ " and " TZDIR
166 give timezone information used by
167 .BR tzset (3)
168 and through that by functions like
169 .BR ctime (3),
170 .BR localtime (3),
171 .BR mktime (3),
172 .BR strftime (3).
173 See also
174 .BR tzselect (8).
175 .LP
176 .B TERMCAP
177 gives information on how to address a given terminal
178 (or gives the name of a file containing such information).
179 .LP
180 .BR COLUMNS " and " LINES
181 tell applications about the window size, possibly overriding the actual size.
182 .LP
183 .BR PRINTER " or " LPDEST
184 may specify the desired printer to use.
185 See
186 .BR lpr (1).
187 .LP
188 Etc.
189 .SH BUGS
190 Clearly there is a security risk here.
191 Many a system command has been
192 tricked into mischief by a user who specified unusual values for
193 .BR IFS " or " LD_LIBRARY_PATH .
194
195 There is also the risk of name space pollution.
196 Programs like
197 .I make
198 and
199 .I autoconf
200 allow overriding of default utility names from the
201 environment with similarly named variables in all caps.
202 Thus one uses
203 .B CC
204 to select the desired C compiler (and similarly
205 .BR MAKE ,
206 .BR AR ,
207 .BR AS ,
208 .BR FC ,
209 .BR LD ,
210 .BR LEX ,
211 .BR RM ,
212 .BR YACC ,
213 etc.).
214 However, in some traditional uses such an environment variable
215 gives options for the program instead of a pathname.
216 Thus, one has
217 .BR MORE ,
218 .BR LESS ,
219 and
220 .BR GZIP .
221 Such usage is considered mistaken, and to be avoided in new
222 programs.
223 The authors of
224 .I gzip
225 should consider renaming their option to
226 .BR GZIP_OPT .
227 .SH "SEE ALSO"
228 .BR bash (1),
229 .BR csh (1),
230 .BR login (1),
231 .BR sh (1),
232 .BR tcsh (1),
233 .BR execve (2),
234 .BR clearenv (3),
235 .BR exec (3),
236 .BR getenv (3),
237 .BR putenv (3),
238 .BR setenv (3),
239 .BR unsetenv (3),
240 .BR locale (5)