Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
environ(7)
Edit
PageHistory
Diff
Info
LikePages
ENVIRON !!!ENVIRON NAME SYNOPSIS DESCRIPTION BUGS SEE ALSO ---- !!NAME environ - user environment !!SYNOPSIS __extern char **environ; __ !!DESCRIPTION The variable ''environ'' points to an array of strings called the `environment'. (This variable must be declared in the user program, but is declared in the header file ''unistd.h'' in case the header files came from libc4 or libc5, and in case they came from glibc and ___GNU_SOURCE__ was defined.) This array of strings is made available to the process by the exec(3) call that started the process. By convention these strings have the form `''name''__=__''value'''. Common examples are: __USER__ The name of the logged-in user (used by some BSD-derived programs). __LOGNAME__ The name of the logged-in user (used by some System-V derived programs). __HOME__ A user's login directory, set by login(1) from the password file passwd(5). __LANG__ The name of a locale to use for locale categories when not overridden by __LC_ALL__ or more specific environment variables like __LC_COLLATE__, __LC_CTYPE__, __LC_MESSAGES__, __LC_MONETARY__, __LC_NUMERIC__, __LC_TIME__, cf. locale(5). __PATH__ The sequence of directory prefixes that sh(1) and many other programs apply in searching for a file known by an incomplete path name. The prefixes are separated by `__:__'. (Similarly one has __CDPATH__ used by some shells to find the target of a change directory command, __MANPATH__ used by man(1) to find manual pages, etc.) __PWD__ The current working directory. Set by some shells. __SHELL__ The file name of the user's login shell. __TERM__ The terminal type for which output is to be prepared. __PAGER__ The user's preferred utility to display text files. __EDITOR__/__VISUAL__ The user's preferred utility to edit text files. __BROWSER__ The user's preferred utility to browse URLs. Sequence of colon-separated browser commands. See http://www.tuxedo.org/~esr/BROWSER/ . Further names may be placed in the environment by the __export__ command and `name=value' in sh(1), or by the __setenv__ command if you use csh(1). Arguments may also be placed in the environment at the point of an exec(2). A C program can manipulate its environment using the functions getenv(3), putenv(3), setenv(3) and unsetenv(3). Note that the behaviour of many programs and library routines is influenced by the presence or value of certain environment variables. A random collection: The variables __LANG__, __LANGUAGE__, __NLSPATH__, __LOCPATH__, __LC_ALL__, __LC_MESSAGES__, etc. influence locale handling, cf. locale(5). __TMPDIR__ influences the path prefix of names created by __tmpnam(3)__ and other routines, the temporary directory used by sort(1) and other programs, etc. __LD_LIBRARY_PATH__, __LD_PRELOAD__ and other LD_* variables influence the behaviour of the dynamic loader/linker. __POSIXLY_CORRECT__ makes certain programs and library routines follow the prescriptions of POSIX. The behaviour of malloc(3) is influenced by MALLOC_* variables. The variable __HOSTALIASES__ gives the name of a file containing aliases to be used with gethostbyname(3). __TZ__ and __TZDIR__ give time zone information. __TERMCAP__ gives information on how to address a given terminal (or gives the name of a file containing such information). __COLUMNS__ and __LINES__ tell applications about the window size, possibly overriding the actual size. __PRINTER__ or __LPDEST__ may specify the desired printer to use. Etc. etc. !!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 __IFS__ or __LD_LIBRARY_PATH__. There is also the risk of name space pollution. Programs like ''make'' and ''autoconf'' allow overriding of default utility names from the environment with similarly named variables in all caps. Thus one uses __CC__ to select the desired C compiler (and similarly __MAKE__, __AR__, __AS__, __FC__, __LD__, __LEX__, __RM__, __YACC__, etc.). However, in some traditional uses such an environment variable gives options for the program instead of a pathname. Thus one has __MORE__, __LESS__, and __GZIP__. Such usage is considered mistaken, and to be avoided in new programs. The authors of ''gzip'' should consider renaming their option to __GZIP_OPT__. !!SEE ALSO login(1), sh(1), bash(1), csh(1), tcsh(1), execve(2), exec(3), getenv(3), putenv(3), setenv(3), unsetenv(3), locale(5) ----
10 pages link to
environ(7)
:
lynx(1)
Man7e
csh(1)
getenv(3)
putenv(3)
reset(1)
setenv(3)
tset(1)
ul(1)
unsetenv(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.