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