Files
2024-02-19 00:21:47 -05:00

738 lines
20 KiB
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 The Open Group, All Rights Reserved -->
<title>getconf</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="getconf"></a> <a name="tag_04_61"></a><!-- getconf -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_04_61_01"></a>NAME</h4>
<blockquote>getconf - get configuration values</blockquote>
<h4><a name="tag_04_61_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>getconf</tt> <b>[</b> <tt>-v specification</tt> <b>]</b> <i>system_var</i><tt><br>
<br>
getconf</tt> <b>[</b> <tt>-v specification</tt> <b>]</b> <i>path_var pathname</i><tt><br>
</tt></code></p>
</blockquote>
<h4><a name="tag_04_61_03"></a>DESCRIPTION</h4>
<blockquote>
<p>In the first synopsis form, the <i>getconf</i> utility shall write to the standard output the value of the variable specified by
the <i>system_var</i> operand.</p>
<p>In the second synopsis form, the <i>getconf</i> utility shall write to the standard output the value of the variable specified
by the <i>path_var</i> operand for the path specified by the <i>pathname</i> operand.</p>
<p>The value of each configuration variable shall be determined as if it were obtained by calling the function from which it is
defined to be available by this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 or by the System Interfaces volume of
IEEE&nbsp;Std&nbsp;1003.1-2001 (see the OPERANDS section). The value shall reflect conditions in the current operating
environment.</p>
</blockquote>
<h4><a name="tag_04_61_04"></a>OPTIONS</h4>
<blockquote>
<p>The <i>getconf</i> utility shall conform to the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
<p>The following option shall be supported:</p>
<dl compact>
<dt><b>-v&nbsp;</b> <i>specification</i></dt>
<dd><br>
Indicate a specific specification and version for which configuration variables shall be determined. If this option is not
specified, the values returned correspond to an implementation default conforming compilation environment.
<p>If the command:</p>
<pre>
<tt>getconf _POSIX_V6_ILP32_OFF32
</tt>
</pre>
<p>does not write <tt>"-1\n"</tt> or <tt>"undefined\n"</tt> to standard output, then commands of the form:</p>
<pre>
<tt>getconf -v POSIX_V6_ILP32_OFF32 ...
</tt>
</pre>
<p>determine values for configuration variables corresponding to the POSIX_V6_ILP32_OFF32 compilation environment specified in <a
href="c99.html"><i>c99</i></a> , the EXTENDED DESCRIPTION.</p>
<p>If the command:</p>
<pre>
<tt>getconf _POSIX_V6_ILP32_OFFBIG
</tt>
</pre>
<p>does not write <tt>"-1\n"</tt> or <tt>"undefined\n"</tt> to standard output, then commands of the form:</p>
<pre>
<tt>getconf -v POSIX_V6_ILP32_OFFBIG ...
</tt>
</pre>
<p>determine values for configuration variables corresponding to the POSIX_V6_ILP32_OFFBIG compilation environment specified in <a
href="c99.html"><i>c99</i></a> , the EXTENDED DESCRIPTION.</p>
<p>If the command:</p>
<pre>
<tt>getconf _POSIX_V6_LP64_OFF64
</tt>
</pre>
<p>does not write <tt>"-1\n"</tt> or <tt>"undefined\n"</tt> to standard output, then commands of the form:</p>
<pre>
<tt>getconf -v POSIX_V6_LP64_OFF64 ...
</tt>
</pre>
<p>determine values for configuration variables corresponding to the POSIX_V6_LP64_OFF64 compilation environment specified in <a
href="c99.html"><i>c99</i></a> , the EXTENDED DESCRIPTION.</p>
<p>If the command:</p>
<pre>
<tt>getconf _POSIX_V6_LPBIG_OFFBIG
</tt>
</pre>
<p>does not write <tt>"-1\n"</tt> or <tt>"undefined\n"</tt> to standard output, then commands of the form:</p>
<pre>
<tt>getconf -v POSIX_V6_LPBIG_OFFBIG ...
</tt>
</pre>
<p>determine values for configuration variables corresponding to the POSIX_V6_LPBIG_OFFBIG compilation environment specified in <a
href="c99.html"><i>c99</i></a> , the EXTENDED DESCRIPTION.</p>
</dd>
</dl>
</blockquote>
<h4><a name="tag_04_61_05"></a>OPERANDS</h4>
<blockquote>
<p>The following operands shall be supported:</p>
<dl compact>
<dt><i>path_var</i></dt>
<dd>A name of a configuration variable. All of the variables in the <a href="../functions/pathconf.html"><i>pathconf</i>()</a>
function defined in the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001 are supported and the implementation may add
other local variables.</dd>
<dt><i>pathname</i></dt>
<dd>A pathname for which the variable specified by <i>path_var</i> is to be determined.</dd>
<dt><i>system_var</i></dt>
<dd>A name of a configuration variable. All of the variables in the <a href="../functions/confstr.html"><i>confstr</i>()</a> and <a
href="../functions/sysconf.html"><i>sysconf</i>()</a> functions defined in the System Interfaces volume of
IEEE&nbsp;Std&nbsp;1003.1-2001 shall be supported and the implementation may add other local values.
<p>When the symbol listed in the first column of the following table is used as the <i>system_var</i> operand, <i>getconf</i>
yields the same value as <a href="../functions/confstr.html"><i>confstr</i>()</a> when called with the value in the second
column:</p>
</dd>
</dl>
<hr>
<table border="1" cellpadding="3">
<tr valign="top">
<th align="center">
<p class="tent"><b>system_var</b></p>
</th>
<th align="center">
<p class="tent"><b>confstr() Name Value</b></p>
</th>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">PATH</p>
</td>
<td align="left">
<p class="tent">_CS_PATH</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_ILP32_OFF32_CFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_ILP32_OFF32_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_ILP32_OFF32_LDFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_ILP32_OFF32_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_ILP32_OFF32_LIBS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_ILP32_OFF32_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_ILP32_OFFBIG_CFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_ILP32_OFFBIG_LDFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_ILP32_OFFBIG_LIBS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_ILP32_OFFBIG_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_LP64_OFF64_CFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_LP64_OFF64_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_LP64_OFF64_LDFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_LP64_OFF64_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_LP64_OFF64_LIBS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_LP64_OFF64_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_LPBIG_OFFBIG_CFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_LPBIG_OFFBIG_LDFLAGS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_LPBIG_OFFBIG_LIBS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_LPBIG_OFFBIG_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">POSIX_V6_WIDTH_RESTRICTED_ENVS</p>
</td>
<td align="left">
<p class="tent">_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent"><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
border="0"> XBS5_ILP32_OFF32_CFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFF32_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFF32_LDFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFF32_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFF32_LIBS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFF32_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFF32_LINTFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFF32_LINTFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFFBIG_CFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFFBIG_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFFBIG_LDFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFFBIG_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFFBIG_LIBS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILP32_OFFBIG_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_ILP32_OFFBIG_LINTFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_ILPBIG_OFF32_LINTFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LP64_OFF64_CFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LP64_OFF64_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LP64_OFF64_LDFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LP64_OFF64_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LP64_OFF64_LIBS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LP64_OFF64_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LP64_OFF64_LINTFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LP64_OFF64_LINTFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LPBIG_OFFBIG_CFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LPBIG_OFFBIG_CFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LPBIG_OFFBIG_LDFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LPBIG_OFFBIG_LDFLAGS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LPBIG_OFFBIG_LIBS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LPBIG_OFFBIG_LIBS</p>
</td>
</tr>
<tr valign="top">
<td align="left">
<p class="tent">XBS5_LPBIG_OFFBIG_LINTFLAGS (<b>LEGACY</b>)</p>
</td>
<td align="left">
<p class="tent">_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
</td>
</tr>
</table>
</blockquote>
<h4><a name="tag_04_61_06"></a>STDIN</h4>
<blockquote>
<p>Not used.</p>
</blockquote>
<h4><a name="tag_04_61_07"></a>INPUT FILES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_04_61_08"></a>ENVIRONMENT VARIABLES</h4>
<blockquote>
<p>The following environment variables shall affect the execution of <i>getconf</i>:</p>
<dl compact>
<dt><i>LANG</i></dt>
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
<dt><i>LC_ALL</i></dt>
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
<dt><i>LC_CTYPE</i></dt>
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
opposed to multi-byte characters in arguments).</dd>
<dt><i>LC_MESSAGES</i></dt>
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
error.</dd>
<dt><i>NLSPATH</i></dt>
<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 of
IEEE&nbsp;Std&nbsp;1003.1-2001, its value shall be written in the following format:</p>
<pre>
<tt>"%s\n", &lt;</tt><i>value</i><tt>&gt;
</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", &lt;</tt><i>value</i><tt>&gt;
</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>&nbsp;0</dt>
<dd>The specified variable is valid and information about its current state was written successfully.</dd>
<dt>&gt;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.
fi
else
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 value
that 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 the
program 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 to
provide a way of finding the configuration-defined default value for the <i>PATH</i> environment variable. Since <i>PATH</i> can be
modified by the user to include directories that could contain utilities replacing the standard utilities, shell scripts need a way
to determine the system-supplied <i>PATH</i> environment variable value that contains the correct search path for the standard
utilities. It was later suggested that access to the other variables described in this volume of IEEE&nbsp;Std&nbsp;1003.1-2001
could 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 can
vary 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 the
system. The output string <tt>"undefined"</tt> is now used to specify this case with exit code 0 because so many things depend on
an 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 System Interfaces volume of IEEE&nbsp;Std&nbsp;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&nbsp;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>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; 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>