.\" 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 <joey@infodrom.org>
.\"
-.TH ENVIRON 7 2014-06-13 "Linux" "Linux Programmer's Manual"
+.TH ENVIRON 7 2017-09-15 "Linux" "Linux Programmer's Manual"
.SH NAME
environ \- user environment
.SH SYNOPSIS
.nf
.BI "extern char **" environ ;
-.br
.fi
.SH DESCRIPTION
The variable
(This variable must be declared in the user program,
but is declared in the header file
.I <unistd.h>
-in case the header files came from libc4 or libc5, and
-in case they came from glibc and
+if the
.B _GNU_SOURCE
-was defined.)
+feature test macro is defined.)
This array of strings is made available to the process by the
.BR exec (3)
call that started the process.
-
+When a child process is created via
+.BR fork (2),
+it inherits a
+.I copy
+of its parent's environment.
+.PP
By convention the strings in
.I environ
have the form "\fIname\fP\fB=\fP\fIvalue\fP".
.\" The user's preferred utility to browse URLs. Sequence of colon-separated
.\" browser commands. See http://www.catb.org/~esr/BROWSER/ .
.PP
-Further names may be placed in the environment by the
+Names may be placed in the shell's environment by the
.I export
-command and "name=value" in
+command in
.BR sh (1),
or by the
.I setenv
command if you use
.BR csh (1).
+.PP
+The initial environment of the shell is populated in various ways,
+such as definitions from
+.IR /etc/environment
+that are processed by
+.BR pam_env (8)
+for all users at login time (on systems that employ
+.BR pam (8)).
+In addition, various shell initialization scripts, such as the system-wide
+.IR /etc/profile
+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
+.IR command .
+Multiple variable definitions, separated by white space, may precede
+.IR command .
+.PP
Arguments may also be placed in the
environment at the point of an
.BR exec (3).
.BR setenv (3),
and
.BR unsetenv (3).
-
+.PP
Note that the behavior of many programs and library routines is
influenced by the presence or value of certain environment variables.
-A random collection:
-.LP
+Examples include the following:
+.IP * 3
The variables
.BR LANG ", " LANGUAGE ", " NLSPATH ", " LOCPATH ", "
.BR LC_ALL ", " LC_MESSAGES ", "
.BR gettext (3),
and
.BR locale (7).
-.LP
+.IP *
.B TMPDIR
influences the path prefix of names created by
-.BR tmpnam (3)
+.BR tempnam (3)
and other routines, and the temporary directory used by
.BR sort (1)
and other programs.
-.LP
-.BR LD_LIBRARY_PATH ", " LD_PRELOAD
-and other LD_* variables influence
-the behavior of the dynamic loader/linker.
-.LP
+.IP *
+.BR LD_LIBRARY_PATH ", " LD_PRELOAD ,
+and other
+.BR LD_*
+variables influence the behavior of the dynamic loader/linker.
+.IP *
.B POSIXLY_CORRECT
makes certain programs and library routines follow
the prescriptions of POSIX.
-.LP
+.IP *
The behavior of
.BR malloc (3)
is influenced by
.B MALLOC_*
variables.
-.LP
+.IP *
The variable
.B HOSTALIASES
gives the name of a file containing aliases
to be used with
.BR gethostbyname (3).
-.LP
+.IP *
.BR TZ " and " TZDIR
give timezone information used by
.BR tzset (3)
.BR strftime (3).
See also
.BR tzselect (8).
-.LP
+.IP *
.B TERMCAP
gives information on how to address a given terminal
(or gives the name of a file containing such information).
-.LP
+.IP *
.BR COLUMNS " and " LINES
tell applications about the window size, possibly overriding the actual size.
-.LP
+.IP *
.BR PRINTER " or " LPDEST
may specify the desired printer to use.
See
.BR lpr (1).
-.LP
-Etc.
+.SH NOTES
+The
+.BR prctl (2)
+.B PR_SET_MM_ENV_START
+and
+.B PR_SET_MM_ENV_END
+operations can be used to control the location of the process's environment.
.SH BUGS
Clearly there is a security risk here.
Many a system command has been
tricked into mischief by a user who specified unusual values for
.BR IFS " or " LD_LIBRARY_PATH .
-
+.PP
There is also the risk of name space pollution.
Programs like
.I make
should consider renaming their option to
.BR GZIP_OPT .
.SH SEE ALSO
-.BR env (1),
.BR bash (1),
.BR csh (1),
+.BR env (1),
.BR login (1),
.BR printenv (1),
.BR sh (1),
.BR setenv (3),
.BR unsetenv (3),
.BR locale (7),
-.BR ld.so (8)
+.BR ld.so (8),
+.BR pam_env (8)