📄 getconf.html
字号:
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_61_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_61_10"></a>STDOUT</h4><blockquote><p>If the specified variable is defined on the system and its value is described to be available from the <a href="../functions/confstr.html"><i>confstr</i>()</a> function defined in the System Interfaces volume ofIEEE Std 1003.1-2001, its value shall be written in the following format:</p><pre><tt>"%s\n", <</tt><i>value</i><tt>></tt></pre><p>Otherwise, if the specified variable is defined on the system, its value shall be written in the following format:</p><pre><tt>"%d\n", <</tt><i>value</i><tt>></tt></pre><p>If the specified variable is valid, but is undefined on the system, <i>getconf</i> shall write using the following format:</p><pre><tt>"undefined\n"</tt></pre><p>If the variable name is invalid or an error occurs, nothing shall be written to standard output.</p></blockquote><h4><a name="tag_04_61_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_61_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_61_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_61_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>The specified variable is valid and information about its current state was written successfully.</dd><dt>>0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_61_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_61_16"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_61_17"></a>EXAMPLES</h4><blockquote><p>The following example illustrates the value of {NGROUPS_MAX}:</p><pre><tt>getconf NGROUPS_MAX</tt></pre><p>The following example illustrates the value of {NAME_MAX} for a specific directory:</p><pre><tt>getconf NAME_MAX /usr</tt></pre><p>The following example shows how to deal more carefully with results that might be unspecified:</p><pre><tt>if value=$(getconf PATH_MAX /usr); then if [ "$value" = "undefined" ]; then echo PATH_MAX in /usr is infinite. else echo PATH_MAX in /usr is $value. fielse echo Error in getconf.fi</tt></pre><p>Note that:</p><pre><tt>sysconf(_SC_POSIX_C_BIND);</tt></pre><p>and:</p><pre><tt>system("getconf POSIX2_C_BIND");</tt></pre><p>in a C program could give different answers. The <a href="../functions/sysconf.html"><i>sysconf</i>()</a> call supplies a valuethat corresponds to the conditions when the program was either compiled or executed, depending on the implementation; the <a href="../functions/system.html"><i>system</i>()</a> call to <i>getconf</i> always supplies a value corresponding to conditions when theprogram is executed.</p></blockquote><h4><a name="tag_04_61_18"></a>RATIONALE</h4><blockquote><p>The original need for this utility, and for the <a href="../functions/confstr.html"><i>confstr</i>()</a> function, was toprovide a way of finding the configuration-defined default value for the <i>PATH</i> environment variable. Since <i>PATH</i> can bemodified by the user to include directories that could contain utilities replacing the standard utilities, shell scripts need a wayto determine the system-supplied <i>PATH</i> environment variable value that contains the correct search path for the standardutilities. It was later suggested that access to the other variables described in this volume of IEEE Std 1003.1-2001could also be useful to applications.</p><p>This functionality of <i>getconf</i> would not be adequately subsumed by another command such as:</p><pre><tt>grep</tt> <i>var</i> <tt>/etc/conf</tt></pre><p>because such a strategy would provide correct values for neither those variables that can vary at runtime, nor those that canvary depending on the path.</p><p>Early proposal versions of <i>getconf</i> specified exit status 1 when the specified variable was valid, but not defined on thesystem. The output string <tt>"undefined"</tt> is now used to specify this case with exit code 0 because so many things depend onan exit code of zero when an invoked utility is successful.</p></blockquote><h4><a name="tag_04_61_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_61_20"></a>SEE ALSO</h4><blockquote><p><a href="c99.html"><i>c99</i></a>, the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/limits.h.html"><i><limits.h></i></a>, the System Interfaces volume of IEEE Std 1003.1-2001, <a href="../functions/confstr.html"><i>confstr</i>()</a>, <a href="../functions/pathconf.html"><i>pathconf</i>()</a>, <a href="../functions/sysconf.html"><i>sysconf</i>()</a>, <a href="../functions/system.html"><i>system</i>()</a></p></blockquote><h4><a name="tag_04_61_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4.</p></blockquote><h4><a name="tag_04_61_22"></a>Issue 5</h4><blockquote><p>In the OPERANDS section:</p><ul><li><p>{NL_MAX} is changed to {NL_NMAX}.</p></li><li><p>Entries beginning NL_ are deleted from the list of standard configuration variables.</p></li><li><p>The list of variables previously marked UX is merged with the list marked EX.</p></li><li><p>Operands are added to support new Option Groups.</p></li><li><p>Operands are added so that <i>getconf</i> can determine supported programming environments.</p></li></ul></blockquote><h4><a name="tag_04_61_23"></a>Issue 6</h4><blockquote><p>The Open Group Corrigendum U029/4 is applied, correcting the example command in the last paragraph of the OPTIONS section.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>Operands are added to determine supported programming environments.</p></li></ul><p>This reference page is updated for alignment with the ISO/IEC 9899:1999 standard. Specifically, new macros for <a href="../utilities/c99.html"><i>c99</i></a> programming environments are introduced.</p><p>XSI marked <i>system_var</i> (XBS5_*) values are marked LEGACY.</p><p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/27 is applied, correcting the descriptions of <i>path_var</i> and<i>system_var</i> in the OPERANDS section.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -