📄 xbd_chap08.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>Environment Variables</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h2><a name="tag_08"></a>Environment Variables</h2><h3><a name="tag_08_01"></a>Environment Variable Definition</h3><p>Environment variables defined in this chapter affect the operation of multiple utilities, functions, and applications. There areother environment variables that are of interest only to specific utilities. Environment variables that apply to a single utilityonly are defined as part of the utility description. See the ENVIRONMENT VARIABLES section of the utility descriptions in the Shelland Utilities volume of IEEE Std 1003.1-2001 for information on environment variable usage.</p><p>The value of an environment variable is a string of characters. For a C-language program, an array of strings called theenvironment shall be made available when a process begins. The array is pointed to by the external variable <i>environ</i>, whichis defined as:</p><blockquote><pre><tt>extern char **environ;</tt></pre></blockquote><p>These strings have the form <i>name</i>=<i>value</i>; <i>name</i>s shall not contain the character <tt>'='</tt> . For values tobe portable across systems conforming to IEEE Std 1003.1-2001, the value shall be composed of characters from theportable character set (except NUL and as indicated below). There is no meaning associated with the order of strings in theenvironment. If more than one string in a process' environment has the same <i>name</i>, the consequences are undefined.</p><p>Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consistsolely of uppercase letters, digits, and the <tt>'_'</tt> (underscore) from the characters defined in <a href="xbd_chap06.html#tagtcjh_3"><i>Portable Character Set</i></a> and do not begin with a digit. Other characters may be permitted byan implementation; applications shall tolerate the presence of such names. Uppercase and lowercase letters shall retain theirunique identities and shall not be folded together. The name space of environment variable names containing lowercase letters isreserved for applications. Applications can define any environment variables with names from this name space without modifying thebehavior of the standard utilities. <basefont size="2"></p><dl><dt><b>Note:</b></dt><dd>Other applications may have difficulty dealing with environment variable names that start with a digit. For this reason, use ofsuch names is not recommended anywhere.</dd></dl><basefont size="3"> <p>The <i>values</i> that the environment variables may be assigned are not restricted except that they are considered to end witha null byte and the total space used to store the environment and the arguments to the process is limited to {ARG_MAX} bytes.</p><p>Other <i>name</i>= <i>value</i> pairs may be placed in the environment by, for example, calling any of the <a href="../functions/setenv.html"><i>setenv</i>()</a>, <a href="../functions/unsetenv.html"><i>unsetenv</i>()</a>, <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or <a href="../functions/putenv.html"><i>putenv</i>()</a> <img src="../images/opt-end.gif" alt="[Option End]" border="0"> functions,manipulating the <i>environ</i> variable, or by using <i>envp</i> arguments when creating a process; see <i>exec</i> in the SystemInterfaces volume of IEEE Std 1003.1-2001.</p><p>It is unwise to conflict with certain variables that are frequently exported by widely used command interpreters andapplications:</p><center><table cellpadding="3" align="center"><tr valign="top"><td align="left"><p class="tent"><i>ARFLAGS</i></p></td><td align="left"><p class="tent"><i>IFS</i></p></td><td align="left"><p class="tent"><i>MAILPATH</i></p></td><td align="left"><p class="tent"><i>PS1</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>CC</i></p></td><td align="left"><p class="tent"><i>LANG</i></p></td><td align="left"><p class="tent"><i>MAILRC</i></p></td><td align="left"><p class="tent"><i>PS2</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>CDPATH</i></p></td><td align="left"><p class="tent"><i>LC_ALL</i></p></td><td align="left"><p class="tent"><i>MAKEFLAGS</i></p></td><td align="left"><p class="tent"><i>PS3</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>CFLAGS</i></p></td><td align="left"><p class="tent"><i>LC_COLLATE</i></p></td><td align="left"><p class="tent"><i>MAKESHELL</i></p></td><td align="left"><p class="tent"><i>PS4</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>CHARSET</i></p></td><td align="left"><p class="tent"><i>LC_CTYPE</i></p></td><td align="left"><p class="tent"><i>MANPATH</i></p></td><td align="left"><p class="tent"><i>PWD</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>COLUMNS</i></p></td><td align="left"><p class="tent"><i>LC_MESSAGES</i></p></td><td align="left"><p class="tent"><i>MBOX</i></p></td><td align="left"><p class="tent"><i>RANDOM</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>DATEMSK</i></p></td><td align="left"><p class="tent"><i>LC_MONETARY</i></p></td><td align="left"><p class="tent"><i>MORE</i></p></td><td align="left"><p class="tent"><i>SECONDS</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>DEAD</i></p></td><td align="left"><p class="tent"><i>LC_NUMERIC</i></p></td><td align="left"><p class="tent"><i>MSGVERB</i></p></td><td align="left"><p class="tent"><i>SHELL</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>EDITOR</i></p></td><td align="left"><p class="tent"><i>LC_TIME</i></p></td><td align="left"><p class="tent"><i>NLSPATH</i></p></td><td align="left"><p class="tent"><i>TERM</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>ENV</i></p></td><td align="left"><p class="tent"><i>LDFLAGS</i></p></td><td align="left"><p class="tent"><i>NPROC</i></p></td><td align="left"><p class="tent"><i>TERMCAP</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>EXINIT</i></p></td><td align="left"><p class="tent"><i>LEX</i></p></td><td align="left"><p class="tent"><i>OLDPWD</i></p></td><td align="left"><p class="tent"><i>TERMINFO</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>FC</i></p></td><td align="left"><p class="tent"><i>LFLAGS</i></p></td><td align="left"><p class="tent"><i>OPTARG</i></p></td><td align="left"><p class="tent"><i>TMPDIR</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>FCEDIT</i></p></td><td align="left"><p class="tent"><i>LINENO</i></p></td><td align="left"><p class="tent"><i>OPTERR</i></p></td><td align="left"><p class="tent"><i>TZ</i></p></td></tr><tr valign="top"><td align="left"><p class="tent"><i>FFLAGS</i></p></td><td align="left"><p class="tent"><i>LINES</i></p></td><td align="left"><p class="tent"><i>OPTIND</i></p></td><td align="left"><p class="tent"><i>USER</i></p></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -