⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 envvar.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>Environment Variables</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><blockquote><center><h2><a name = "tag_002">&nbsp;</a>Environment Variables</h2></center><xref type="1" name="envvar"></xref><h3><a name = "tag_002_001">&nbsp;</a>Environment Variable Definition</h3>Environment variables defined in this chapteraffect the operation ofmultiple utilities,functions and applications.There are other environment variables that are of interest onlyto specific utilities.Environment variables that apply to a single utility only aredefined as part of the utility description.See the<b>ENVIRONMENT VARIABLES</b>section of the utility descriptions in the <b>XCU</b> specification for information on environmentvariable usage.<p>The value of an environment variable is a stringof characters.For a C-language program,an array of strings called the environment is made availablewhen a process begins.The array is pointed to by the external variable<i>environ</i>,which is defined as:<code><pre>extern char **environ;</code></pre><p>These strings have the formdo not contain the character =.For values to be portable acrossXSI-conformant systems, the value must be composed of charactersfrom the portable character set (except NULand as indicated below).There is no meaning associated with the order of strings in the environment.If more than one string in a process' environmenthas the samethe consequences are undefined.<p>Environment variable names used by the utilities in the <b>XCU</b> specificationconsist solely of upper-case letters,digits and the "_" (underscore) from the characters defined in<xref href=portchar><a href="charset.html#tagt_1">Portable Character Set</a></xref>.Other characters may be permitted by an implementation;applications must tolerate the presence of such names.Upper- andlower-case letters retain their unique identities and are not folded together.The name space of environment variable names containing lower-caseletters is reserved for applications.Applications can defineany environment variables with names from this name space withoutmodifying the behaviour of the standard utilities.<p>The<i>values</i>that the environment variables may be assigned are not restricted except thatthey are considered to end with a null byte and the total space usedto store the environment and the arguments to the process is limited to{ARG_MAX}bytes.<p>Otherpairs may be placed in the environment by, for example,calling the<i><a href="../xsh/putenv.html">putenv()</a></i>function,manipulating the<i>environ</i>variable, or by using<i>envp</i>arguments when creating a process; seein the <b>XSH</b> specification.<p>It is unwise to conflict with certain variables that arefrequently exported by widely used command interpreters andapplications:<pre><table  bordercolor=#000000 border=1 align=center><tr valign=top><td align=left>ARFLAGS<td align=left>IFS<td align=left>MAILPATH<td align=left>PS1<tr valign=top><td align=left>CC<td align=left>LANG<td align=left>MAILRC<td align=left>PS2<tr valign=top><td align=left>CDPATH<td align=left>LC_ALL<td align=left>MAKEFLAGS<td align=left>PS3<tr valign=top><td align=left>CFLAGS<td align=left>LC_COLLATE<td align=left>MAKESHELL<td align=left>PS4<tr valign=top><td align=left>CHARSET<td align=left>LC_CTYPE<td align=left>MANPATH<td align=left>PWD<tr valign=top><td align=left>COLUMNS<td align=left>LC_MESSAGES<td align=left>MBOX<td align=left>RANDOM<tr valign=top><td align=left>DATEMSK<td align=left>LC_MONETARY<td align=left>MORE<td align=left>SECONDS<tr valign=top><td align=left>DEAD<td align=left>LC_NUMERIC<td align=left>MSGVERB<td align=left>SHELL<tr valign=top><td align=left>EDITOR<td align=left>LC_TIME<td align=left>NLSPATH<td align=left>TERM<tr valign=top><td align=left>ENV<td align=left>LDFLAGS<td align=left>NPROC<td align=left>TERMCAP<tr valign=top><td align=left>EXINIT<td align=left>LEX<td align=left>OLDPWD<td align=left>TERMINFO<tr valign=top><td align=left>FC<td align=left>LFLAGS<td align=left>OPTARG<td align=left>TMPDIR<tr valign=top><td align=left>FCEDIT<td align=left>LINENO<td align=left>OPTERR<td align=left>TZ<tr valign=top><td align=left>FFLAGS<td align=left>LINES<td align=left>OPTIND<td align=left>USER<tr valign=top><td align=left>GET<td align=left>LISTER<td align=left>PAGER<td align=left>VISUAL<tr valign=top><td align=left>GFLAGS<td align=left>LOGNAME<td align=left>PATH<td align=left>YACC<tr valign=top><td align=left>HISTFILE<td align=left>LPDEST<td align=left>PPID<td align=left>YFLAGS<tr valign=top><td align=left>HISTORY<td align=left>MAIL<td align=left>PRINTER<td align=left>&nbsp;<tr valign=top><td align=left>HISTSIZE<td align=left>MAILCHECK<td align=left>PROCLANG<td align=left>&nbsp;<tr valign=top><td align=left>HOME<td align=left>MAILER<td align=left>PROJECTDIR<td align=left>&nbsp;</table></pre><p>If the variables in the followingtwo sections are present in the environmentduring the execution of an application or utility, they are given the meaningdescribed below.Some are placedinto the environment by the implementationat the time the user logs in;all can be added or changed by the useror any ancestor of the current process.The implementation will add or change environmentvariables named in this specification set only asspecified in this specification set.If they are defined in the application'senvironment, the utilities in the <b>XCU</b> specification andthe functions in the <b>XSH</b> specification assume they have the specified meaning.Conforming applicationsmust not set these environment variablesto have meanings other than as described.See<i><a href="../xsh/getenv.html">getenv()</a></i>andthe <b>XCU</b> specification, <a href="../xcu/chap2.html#tag_001_012"><b>Shell Execution Environment</b>&nbsp;</a>for methods of accessing these variables.<h3><a name = "tag_002_002">&nbsp;</a>Internationalisation Variables</h3><p>This section describes environment variables that are relevant to theoperation of internationalised interfaces described in theCAE Specification, <b>System Interfaces and Headers</b>, <b>Issue 5</b> and the CAE Specification, <b>Commands and Utilities, Issue 5</b>.<p>Users may use the following environment variables to announce specificlocalisation requirements to applications.Applications must retrieve this information using the<i><a href="../xsh/setlocale.html">setlocale()</a></i>function to initialise the correct behaviour of the internationalisedinterfaces.The descriptions of the internationalisation environment variablesdescribe the resulting behaviour only when the application localeis initialised in this way.<dl compact><dt><i>LANG</i><dd><index term="LANG, "></index>This variable determines the locale category for native language,local customs and coded character set in the absence of the<i>LC_ALL</i>and other<i>LC_*</i> (<i>LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY,LC_NUMERIC, LC_TIME</i>)environment variables.This can be used byapplications to determine the language to use for error messagesand instructions, collating sequences, date formats, and so forth.<dt><i>LC_ALL</i><dd><index term="LC_ALL, "></index>This variable determines the values for all locale categories.The value of the<i>LC_ALL</i>environment variable has precedence over any ofthe other environment variables starting with<i>LC_</i> (<i>LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY,LC_NUMERIC, LC_TIME</i>)and the<i>LANG</i>environment variable.<dt><i>LC_COLLATE</i><dd><index term="LC_COLLATE, "></index>This variable determines the locale category for character collation.It determines collationinformation for regular expressions and sorting, includingequivalence classes and multi-character collating elements,in various utilities and the<i><a href="../xsh/strcoll.html">strcoll()</a></i>and<i><a href="../xsh/strxfrm.html">strxfrm()</a></i>functions.Additional semantics of this variable, if any, are implementation-dependent.<dt><i>LC_CTYPE</i><dd><index term="LC_CTYPE, "></index>This variable determines thelocale category for character handling functions,such as<i><a href="../xsh/tolower.html">tolower()</a></i>,<i><a href="../xsh/toupper.html">toupper()</a></i>and<i><a href="../xsh/isalpha.html">isalpha()</a></i>.This environment variable determinesthe interpretation of sequences of bytes of textdata as characters (for example, single- as opposed tomulti-byte characters), the classification ofcharacters (for example, alpha, digit, graph) and thebehaviour of character classes.Additional semantics of this variable, if any, are implementation-dependent.<dt><i>LC_MESSAGES</i><dd><index term="LC_MESSAGES, "></index>This variable determines the locale category for processing affirmative andnegative responses and the language and cultural conventions in which messagesshould be written.It also affects the behaviour of the<i><a href="../xsh/catopen.html">catopen()</a></i>function in determining the message catalogue.Additional semantics of this variable, if any, are implementation-dependent.The language and cultural conventions of diagnostic andinformative messages whose format is unspecifiedby this specification set should be affected by the setting of<i>LC_MESSAGES</i>.<dt><i>LC_MONETARY</i><dd><index term="LC_MONETARY, "></index>This variable determines thelocale category for monetary-related numeric formatting information.Additional semantics of this variable, if any, are implementation-dependent.<dt><i>LC_NUMERIC</i><dd><index term="LC_NUMERIC, "></index>This variable determines thelocale category for numeric formatting (for example, thousands separatorand radix character) informationin various utilities as well as the formatted I/O operations in<i><a href="../xsh/printf.html">printf()</a></i>and<i><a href="../xsh/scanf.html">scanf()</a></i>and the string conversion functions in<i><a href="../xsh/strtod.html">strtod()</a></i>.Additional semantics of this variable, if any, are implementation-dependent.<dt><i>LC_TIME</i><dd><index term="LC_TIME, "></index>This variable determines thelocale category for date and time formatting information.It affects the behaviour of the time functions in<i><a href="../xsh/strftime.html">strftime()</a></i>.Additional semantics of this variable, if any, are implementation-dependent.<dt><i>NLSPATH</i><dd><index term="NLSPATH, "></index>This variable contains a sequence of templates that the<i><a href="../xsh/catopen.html">catopen()</a></i>function uses when attempting to locate message catalogues.Each template consists ofan optional prefix,one or more substitution fields,a filename and an optional suffix.For example:<code><pre>NLSPATH="/system/nlslib/%N.cat"</code></pre>defines that<i><a href="../xsh/catopen.html">catopen()</a></i>should look for all message catalogues in thedirectory<b>/system/nlslib</b>,where the catalogue name should be constructed from the<i>name</i>parameter passed to<i><a href="../xsh/catopen.html">catopen()</a></i>(<b>%N</b>),with the suffix<b>.cat</b>.Substitution fields consist of a "%"symbol, followed by a single-letter keyword.The following keywords are currently defined:<dl compact><dt>%N<dd>The value of the<i>name</i>parameter passed to<i><a href="../xsh/catopen.html">catopen()</a></i>.<dt>%L<dd>The value ofthe LC_MESSAGES category.<dt>%l<dd>The<i>language</i>element fromthe LC_MESSAGES category.<dt>%t<dd>The<i>territory</i>element fromthe LC_MESSAGES category.<dt>%c<dd>The<i>codeset</i>element fromthe LC_MESSAGES category.<dt>%%<dd>A single % character.</dl><p>An empty string is substituted if the specified value is notcurrently defined.The separators underscore (_) and period (.) are not included in%t and %c substitutions.<p>Templates defined in<i>NLSPATH</i>are separated by colons (:).A leading or two adjacent colons :: is equivalent tospecifying %N.For example:<code><pre>NLSPATH=":%N.cat:/nlslib/%L/%N.cat"</code></pre>indicates to<i><a href="../xsh/catopen.html">catopen()</a></i>that it should look for the requested message catalogue in <i>name</i>,<i>name</i><b>.cat</b> and <b>/nlslib/</b><i>category</i><b>/</b><i>name</i><b>.cat</b>, where<i>category</i>is the value of the LC_MESSAGES category of the current locale.<p>Users should not set the<i>NLSPATH</i>variable unless they have a specific reason to overridethe default system path.Doing so causes undefined behaviour in the standard utilities.<p></dl><p>The environment variables<i>LANG</i>,<i>LC_ALL</i>,<i>LC_COLLATE</i>,<i>LC_CTYPE</i>,<i>LC_MESSAGES</i>,<i>LC_MONETARY</i>,<i>LC_NUMERIC</i>,<i>LC_TIME</i>,<i>(LC_*)</i>,and<i>NLSPATH</i>provide for the support of internationalised applications.The standard utilities make use of theseenvironment variables as described in this section and theindividual<b>ENVIRONMENT VARIABLES</b>sections for the utilities.If these variables specify locale categoriesthat are not based upon the sameunderlying codeset, the results are unspecified.<p>The values of locale categories are determined by a precedence order;the first condition met below determines the value:<ol><p><li>If the<i>LC_ALL</i>environment variable is defined and isnot null, the value of<i>LC_ALL</i>is used.<p><li>If the<i>LC_*</i>environment variable( <i>LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME</i>)is defined and is not null, the value of theenvironment variable is used to initialise thecategory that corresponds to the environment variable.<p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -