GETCONF(1) General Commands Manual GETCONF(1)

getconfget configuration values

getconf system_var

getconf path_var pathname

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 standard or by POSIX. 1 {8} (see Operands). The value shall reflect conditions in the current operating environment.

None.

The following operands shall be supported by the implementation: system_var A name of a configuration variable whose value is available from the function defined in 7.8.1 [such as () in the C binding], from the POSIX. 1 {8} sysconf() function, one of the additional POSIX. 2 variables described in 7.8.2, to be available from the sysconf() function, or a minimum value specified by POSIX. 1 {8} or POSIX. 2 for one of these variables. The configuration variables and minimum values listed in the:

  • Name column of Table 2-16 (Utility Limit Minimum Values)
  • Name column of Table 2-17 (Symbolic Utility Limits)
  • Name column of Table 2-18 (Optional Facility Configuration Values)
  • Name column of POSIX. 1 {8} Table 2-3 (Minimum Values)
  • Name column of POSIX. 1 {8} Table 2-4 (Run-Time Increasable Values)
  • Variable column of POSIX. 1 {8} Table 4-2 (Configurable System Variables; except need not be supported), without the enclosing braces and PATH [corresponding to the confstr() name value _CS_PATH] shall be recognized as valid system_var operands. The implementation may support additional system_var operand values. path_var A name of a configuration variable whose value is available from the POSIX. 1 {8} () function. The configuration variables listed in the Variable column of the POSIX. 1 {8} Table 5-2 (Configurable Pathname Variables), without the enclosing braces, shall be recognized as valid path_var operands. The implementation may support additional path_var operand values. pathname A pathname for which the variable specified by path_var is to be determined.

None.

None.

The following environment variables shall affect the execution of getconf:

This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.

This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.

This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).

This variable shall determine the language in which messages should be written.

Default.

If the specified variable is defined on the system and its value is described to be available from the function in 7.8.1, 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.

Used only for diagnostic messages.

None.

None.

The getconf utility shall exit with one of the following values:

The specified variable is valid and information about its current state was written successfully.

An error occurred.

Default.

The original need for this utility, and for the () 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 POSIX. 2 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 here could also be useful to applications. This example illustrates the value of NGROUPS_MAX:

getconf NGROUPS_MAX This example illustrates the value of NAME_MAX for a specific directory: getconf NAME_MAX /usr This 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 "); in a C program could give different answers. The () call supplies a value that corresponds to the conditions when the program was either compiled or executed, depending on the implementation; the () call to getconf always supplies a value corresponding to conditions when the program is executed.

This utility was renamed from posixconf during balloting because the new name expresses its purpose more specifically, and does not unduly restrict the scope of application of the utility. This functionality of this utility 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 run-time, nor those that can vary depending on the path. Previous versions of this utility 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.

September 1991 posix.fail