metadb

metadb

NAME

metadb - retrieve configuration information

SYNOPSIS

metadb [ -options ...] key [ ... ]

DESCRIPTION

metadb retrieves string values associates with keys in configuration files. The key(s) to be retrieved are specified as arguments. The configuration file is located through the enviroment variable METADB_CONFIG, possibly overridden by the -config option.

Scripts and programs that need to operate on a variety of data or with different parameters should retrieve all variable information via metadb.

CONFIG FILE SYNTAX

The format of a line in the configuration file is
key value
where key is the first word in a line. Anything starting with the second word is the value associated with the key. Initial and final whitespace is removed, but otherwise whitespace can be embedded in the value. Only the first of multiple lines with the same key is significant for a lookup, unless the -all flag was given.

The special key INCLUDE is used to perform file inclusions:
INCLUDE /some/other/config/file
allowing config files to ``inherit'' from other config files. Note that key-value pairs preceding an inclusion override any identical key in the included file.

The ALIAS keyword redirects a lookup for one key key1 by another lookup for key2:
ALIAS key1 key2

The ALIAS_SUFFIX keyword redirects a lookup for any key with suffix suffix1 to another lookup with the suffix replaced by suffix2:
ALIAS_SUFFIX suffix1 suffix2
This is a convenient way to apply a string mapping to an entire family of keys. To avoid infinite recursions and ambiguities in matching keys, the prefix of the key that is matched by suffix1 must no contain any underscore characters.

Lines containing only whitespace or starting with a pound sign are ignored:
# this is a comment

There is also a primitive macro facility:
DEFINE string string2
causes string to be replaced by string2 in the output.
SDEFINE string comand arg1 arg2 ...
defines string as a macro expanding to the first line of output of command. This also allows ``importing'' environment variables:
SDEFINE MACHINE_TYPE printenv MACHINE_TYPE
(but note the expansion of macros inside the config file does not use dollar signs).
The directive
MDEFINE string key
defines string as a macro expanding to the result of looking up key using metadb itself in the current configuration file. This allows piecing together of strings from various key values, and other back-handed uses.
UNDEF string
undoes the definition of string.

Macros are expanded in key values, include filenames, and the definitions of other macros (at the time of definition).

OPTIONS

-config file
Use file as the configuration file, instead of $METADB_CONFIG.
-all
Return all key values, instead of the first value. This allows using multiple instances of a key to construct lists of strings.
-dump
Output all key-value pairs found in the config file (prior to any values indexed by command line arguments).
-includes
Trace the names of INCLUDEd files.
-e
Print an error message and exit with error status if a requested key value is undefined or empty.
-q
Check for the presence of a key and do not output key values. A program exit status of 0 (``true'' to the shell) indicates that at least one of the keys is present in the configuration file. Otherwise, a status of 1 (``false'' to the shell) is returned.

BUGS

Probably.

AUTHOR

Andreas Stolcke <stolcke@speech.sri.com>.
Copyright 1999-2010 SRI International