defread(1M) —
NAME
defread − read entries from default files
SYNOPSIS
defread [ −b ] [ −B ] [ −c ] [ −d default ] [ −f size ] [ −q ] [ −s ] [ −S ]
[ −u user_format ] [ −v ] [ −V ] token ... [ token ]
DESCRIPTION
defread allows individual tokens to be retrieved from one or more files. A token is a word at the first column of a configuration file. It must be followed by an equal sign and a value (for example, TIMEZONE=EST5EDT). By default, all of the files in the /etc/default directory are searched for tokens. The −f filename option allows any specified file to be searched. defread is intended to be used by, for example, scripts in /etc/rc* to assign variables and values using system-specific configuration files in /etc/default.
OPTIONS
−b Treat the value as a Boolean value. If the value for the given token is “0,” “no,” or “false,” an ‘f’ is printed. If the value for the given token is “1,” “yes,” or “true,” a ‘y’ is printed. If the value for the given token is none of these, nothing is printed.
−B Treat the value as a Boolean value. If the value for the given token is “0,” “no,” or “false,” defread exits with a status of 1. If the value for the given token is “1,” “yes,” or “true,” defread exits with a status of 0.
−c Ignores the case of the characters in the strings.
−d default
default is printed if the token name cannot be found. In the case of the −B option, default can be “yes,” “no,” “true,” “false,” or a number. If it is not one of these choices, defread exits with a status of 1. If default is a number, defread exits with that number. If it is “yes” or “true,” defread exits with a status of 0. Otherwise, it exits with 1.
−f filename
filename is the name of the file to search for tokens. The default is all files in the /etc/default directory.
−q Prints quotes around any found values.
−s Does not print errors.
−S Suppresses multiple matches. Normally, if there is more than one file containing token, the value is printed from each file. This option suppresses all but the first match found.
−u user_format
With this option, the output format of any matching token can be specified. user_format is comprised of a series of control strings. Anything that is not a control string is printed as it appears in the user_format string.
Control Strings:
%t% Prints the token (without the equal sign).
%f% Prints the filename in which the match was found.
%c% Prints the first character of the value.
176 Prints the first character of the value in upper case.
%v% Prints the entire value string.
%V% Prints the value in upper case.
−v Verbose mode shows the token followed by ’=’ then the value. This is the behavior when multiple tokens are specified; if only one token is specified, the default behavior is to show only the value.
−V Very verbose option works in the same way as the −v option but prepends the filename that the token was found in.
EXIT STATUS
defread returns:
−1 (255 for /bin/sh) if the token could not be found. −2 (254 for /bin/sh) if the file could not be found or opened. −3 (253 for /bin/sh) if an invalid value was passed. 0 if one or more tokens were found.
Note that the exit values for the −B option will be different if there is a default value passed (see above).
FILES
/etc/default default directory to search.
NOTES
The maximum number of tokens that can be passed is 32.
ADDED VALUE
This entry, supplied by SunSoft, Inc., is an extension of UNIX System V.
\*U — Version 1.0