The Open Group Base Specifications Issue 6
IEEE Std 1003.1-2001
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.

NAME

getconf - get configuration values

SYNOPSIS

getconf [ -v specification ] system_var

getconf
[ -v specification ] path_var pathname

DESCRIPTION

In the first synopsis form, the getconf utility shall write to the standard output the value of the variable specified by the system_var operand.

In the second synopsis form, the getconf utility shall write to the standard output the value of the variable specified by the path_var operand for the path specified by the pathname operand.

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 Std 1003.1-2001 or by the System Interfaces volume of IEEE Std 1003.1-2001 (see the OPERANDS section). The value shall reflect conditions in the current operating environment.

OPTIONS

The getconf utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.

The following option shall be supported:

-v  specification

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.

If the command:

getconf _POSIX_V6_ILP32_OFF32

does not write "-1\n" or "undefined\n" to standard output, then commands of the form:

getconf -v POSIX_V6_ILP32_OFF32 ...

determine values for configuration variables corresponding to the POSIX_V6_ILP32_OFF32 compilation environment specified in c99 , the EXTENDED DESCRIPTION.

If the command:

getconf _POSIX_V6_ILP32_OFFBIG

does not write "-1\n" or "undefined\n" to standard output, then commands of the form:

getconf -v POSIX_V6_ILP32_OFFBIG ...

determine values for configuration variables corresponding to the POSIX_V6_ILP32_OFFBIG compilation environment specified in c99 , the EXTENDED DESCRIPTION.

If the command:

getconf _POSIX_V6_LP64_OFF64

does not write "-1\n" or "undefined\n" to standard output, then commands of the form:

getconf -v POSIX_V6_LP64_OFF64 ...

determine values for configuration variables corresponding to the POSIX_V6_LP64_OFF64 compilation environment specified in c99 , the EXTENDED DESCRIPTION.

If the command:

getconf _POSIX_V6_LPBIG_OFFBIG

does not write "-1\n" or "undefined\n" to standard output, then commands of the form:

getconf -v POSIX_V6_LPBIG_OFFBIG ...

determine values for configuration variables corresponding to the POSIX_V6_LPBIG_OFFBIG compilation environment specified in c99 , the EXTENDED DESCRIPTION.

OPERANDS

The following operands shall be supported:

path_var
A name of a configuration variable. All of the variables in the pathconf() function defined in the System Interfaces volume of IEEE Std 1003.1-2001 are supported and the implementation may add other local variables.
pathname
A pathname for which the variable specified by path_var is to be determined.
system_var
A name of a configuration variable. All of the variables in the confstr() and sysconf() functions defined in the System Interfaces volume of IEEE Std 1003.1-2001 shall be supported and the implementation may add other local values.

When the symbol listed in the first column of the following table is used as the system_var operand, getconf yields the same value as confstr() when called with the value in the second column:


system_var

confstr() Name Value

PATH

_CS_PATH

POSIX_V6_ILP32_OFF32_CFLAGS

_CS_POSIX_V6_ILP32_OFF32_CFLAGS

POSIX_V6_ILP32_OFF32_LDFLAGS

_CS_POSIX_V6_ILP32_OFF32_LDFLAGS

POSIX_V6_ILP32_OFF32_LIBS

_CS_POSIX_V6_ILP32_OFF32_LIBS

POSIX_V6_ILP32_OFFBIG_CFLAGS

_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS

POSIX_V6_ILP32_OFFBIG_LDFLAGS

_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS

POSIX_V6_ILP32_OFFBIG_LIBS

_CS_POSIX_V6_ILP32_OFFBIG_LIBS

POSIX_V6_LP64_OFF64_CFLAGS

_CS_POSIX_V6_LP64_OFF64_CFLAGS

POSIX_V6_LP64_OFF64_LDFLAGS

_CS_POSIX_V6_LP64_OFF64_LDFLAGS

POSIX_V6_LP64_OFF64_LIBS

_CS_POSIX_V6_LP64_OFF64_LIBS

POSIX_V6_LPBIG_OFFBIG_CFLAGS

_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS

POSIX_V6_LPBIG_OFFBIG_LDFLAGS

_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS

POSIX_V6_LPBIG_OFFBIG_LIBS

_CS_POSIX_V6_LPBIG_OFFBIG_LIBS

POSIX_V6_WIDTH_RESTRICTED_ENVS

_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS

[XSI] [Option Start] XBS5_ILP32_OFF32_CFLAGS (LEGACY)

_CS_XBS5_ILP32_OFF32_CFLAGS

XBS5_ILP32_OFF32_LDFLAGS (LEGACY)

_CS_XBS5_ILP32_OFF32_LDFLAGS

XBS5_ILP32_OFF32_LIBS (LEGACY)

_CS_XBS5_ILP32_OFF32_LIBS

XBS5_ILP32_OFF32_LINTFLAGS (LEGACY)

_CS_XBS5_ILP32_OFF32_LINTFLAGS

XBS5_ILP32_OFFBIG_CFLAGS (LEGACY)

_CS_XBS5_ILP32_OFFBIG_CFLAGS

XBS5_ILP32_OFFBIG_LDFLAGS (LEGACY)

_CS_XBS5_ILP32_OFFBIG_LDFLAGS

XBS5_ILP32_OFFBIG_LIBS (LEGACY)

_CS_XBS5_ILP32_OFFBIG_LIBS

XBS5_ILP32_OFFBIG_LINTFLAGS (LEGACY)

_CS_XBS5_ILPBIG_OFF32_LINTFLAGS

XBS5_LP64_OFF64_CFLAGS (LEGACY)

_CS_XBS5_LP64_OFF64_CFLAGS

XBS5_LP64_OFF64_LDFLAGS (LEGACY)

_CS_XBS5_LP64_OFF64_LDFLAGS

XBS5_LP64_OFF64_LIBS (LEGACY)

_CS_XBS5_LP64_OFF64_LIBS

XBS5_LP64_OFF64_LINTFLAGS (LEGACY)

_CS_XBS5_LP64_OFF64_LINTFLAGS

XBS5_LPBIG_OFFBIG_CFLAGS (LEGACY)

_CS_XBS5_LPBIG_OFFBIG_CFLAGS

XBS5_LPBIG_OFFBIG_LDFLAGS (LEGACY)

_CS_XBS5_LPBIG_OFFBIG_LDFLAGS

XBS5_LPBIG_OFFBIG_LIBS (LEGACY)

_CS_XBS5_LPBIG_OFFBIG_LIBS

XBS5_LPBIG_OFFBIG_LINTFLAGS (LEGACY)

_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS [Option End]

STDIN

Not used.

INPUT FILES

None.

ENVIRONMENT VARIABLES

The following environment variables shall affect the execution of getconf:

LANG
Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
LC_ALL
If set to a non-empty string value, override the values of all the other internationalization variables.
LC_CTYPE
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).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
[XSI] [Option Start] Determine the location of message catalogs for the processing of LC_MESSAGES . [Option End]

ASYNCHRONOUS EVENTS

Default.

STDOUT

If the specified variable is defined on the system and its value is described to be available from the confstr() function defined in the System Interfaces volume of IEEE Std 1003.1-2001, its value shall be written in the following format:

"%s\n", <value>

Otherwise, if the specified variable is defined on the system, its value shall be written in the following format:

"%d\n", <value>

If the specified variable is valid, but is undefined on the system, getconf shall write using the following format:

"undefined\n"

If the variable name is invalid or an error occurs, nothing shall be written to standard output.

STDERR

The standard error shall be used only for diagnostic messages.

OUTPUT FILES

None.

EXTENDED DESCRIPTION

None.

EXIT STATUS

The following exit values shall be returned:

 0
The specified variable is valid and information about its current state was written successfully.
>0
An error occurred.

CONSEQUENCES OF ERRORS

Default.


The following sections are informative.

APPLICATION USAGE

None.

EXAMPLES

The following example illustrates the value of {NGROUPS_MAX}:

getconf NGROUPS_MAX

The following example illustrates the value of {NAME_MAX} for a specific directory:

getconf NAME_MAX /usr

The following example shows how to deal more carefully with results that might be unspecified:

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

Note that:

sysconf(_SC_POSIX_C_BIND);

and:

system("getconf POSIX2_C_BIND");

in a C program could give different answers. The sysconf() call supplies a value that corresponds to the conditions when the program was either compiled or executed, depending on the implementation; the system() call to getconf always supplies a value corresponding to conditions when the program is executed.

RATIONALE

The original need for this utility, and for the confstr() function, was to provide a way of finding the configuration-defined default value for the PATH environment variable. Since PATH 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 PATH 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 Std 1003.1-2001 could also be useful to applications.

This functionality of getconf would not be adequately subsumed by another command such as:

grep var /etc/conf

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.

Early proposal versions of getconf specified exit status 1 when the specified variable was valid, but not defined on the system. The output string "undefined" 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.

FUTURE DIRECTIONS

None.

SEE ALSO

c99 , the System Interfaces volume of IEEE Std 1003.1-2001, confstr(), pathconf(), sysconf(), system()

CHANGE HISTORY

First released in Issue 4.

Issue 5

In the OPERANDS section:

Issue 6

The Open Group Corrigendum U029/4 is applied, correcting the example command in the last paragraph of the OPTIONS section.

The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:

This reference page is updated for alignment with the ISO/IEC 9899:1999 standard. Specifically, new macros for c99 programming environments are introduced.

XSI marked system_var (XBS5_*) values are marked LEGACY.

End of informative text.


UNIX ® is a registered Trademark of The Open Group.
POSIX ® is a registered Trademark of The IEEE.
[ Main Index | XBD | XCU | XSH | XRAT ]