diff options
Diffstat (limited to 'lib/util/config.bash')
-rw-r--r-- | lib/util/config.bash | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/util/config.bash b/lib/util/config.bash index 9817cf3..703dc4d 100644 --- a/lib/util/config.bash +++ b/lib/util/config.bash @@ -55,6 +55,20 @@ config_for() { [[ ! -f $file ]] && continue + # Check if the lookup is a reference variable, defined by using + # &= instead of just a single = as seperator. If this exists, + # do a new config_for lookup, this time using the value as the + # key for the new lookup. + value="$(awk -F= '$1 == "'"$key"'&" { print $0 }' "$file" | cut -d'=' -f 2-)" + + if [[ -n $value ]] + then + debug "bashtard/config_for" "Found reference for $key to $value in $file" + + printf "%s" "$(config_for "$host" "$value")" + return + fi + # Use awk to find the right line, then use cut to get the # actual value. Cutting it out with awk _is_ possible, but # comes with whitespace issues or having to deal with values |