user configurable overlay configuration files

The following overlay configuration files are read:
1. The file defined in the environment variable PMODULES_OVERLAY_CONF
   if set.
2. ${HOME}/.Pmodules/overlays.conf
3. ${PMODULES_ROOT}/config/overlays.conf
This commit is contained in:
2021-12-07 13:25:51 +01:00
parent 5101847bda
commit ca2da5b90e
+14 -2
View File
@@ -413,18 +413,30 @@ declare -r OVERLAY_CONF="${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/overlays.conf"
# Return overlay name *and* directory for an overlay given
# by name *or* directory. Search in the config file ${OVERLAY_CONF}.
#
# Arguments
# $1: name or directory of overlay
#
get_overlay_name_and_dir() {
local "$1" # upvar for overlay name
local "$2" # upvar for overlay directory
if [[ -r "${OVERLAY_CONF}" ]]; then
local config_files=()
if [[ -v PMODULES_OVERLAY_CONF ]]; then
config_files+=("${PMODULES_OVERLAY_CONF}")
fi
config_files+=("${HOME}/.Pmodules/overlay.conf")
config_files+=("${OVERLAY_CONF}")
for config_file in "${config_files[@]}"; do
[[ -r "${OVERLAY_CONF}" ]] || continue
local toks=()
while read -a toks; do
[[ -n "${toks[0]}" ]] || continue
[[ ! "${toks[0]}" =~ \#* ]] || continue
if [[ ${toks[0]} == $3 ]] || [[ ${toks[1]} == $3 ]]; then
std::upvar $1 "${toks[0]}"
std::upvar $2 "${toks[1]}"
return 0
fi
done < "${OVERLAY_CONF}"
done < "${config_file}"
fi
return 1
}