This is easy to do, simple to implement, and backwards compatible
(assuming that nobody has names of config files which contain spaces).
If an option is set both in the environment and in the config file,
the environment takes precedence.
+The `$gsu_config_file` variable can actually contain more than one
+filename, separated by spaces. The config files are processed in
+order, so that an option that is specified in the second config file
+overwrites the definition given in the first. This is useful for
+applications which implement a system-wide config file in addition
+to a per-user config file.
+
___Checking config options___
The gsu config module defines two public functions for this purpose:
# file.
gsu_check_options()
{
- local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}" val orig_val
+ local i f conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}" val orig_val
local name option_type default_value required description help_text
for ((i=0; i < ${#gsu_options[@]}; i++)); do
eval orig_${gsu_config_var_prefix}_$name='"'${val}'"'
done
- [[ -r "$conf" ]] && source "$conf"
+ for f in $conf; do
+ [[ -r "$f" ]] && source "$f"
+ done
for ((i=0; i < ${#gsu_options[@]}; i++)); do
name=