From f3008bb0a8a8d8e8764dde54a05451331c4df85f Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Thu, 4 Jan 2024 11:39:09 +0100 Subject: Fix values with = being used for templating --- lib/util/config.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/util/config.bash') diff --git a/lib/util/config.bash b/lib/util/config.bash index 4727706..76b6567 100644 --- a/lib/util/config.bash +++ b/lib/util/config.bash @@ -51,7 +51,12 @@ config_for() { [[ ! -f $file ]] && continue - value="$(awk -F= '$1 == "'"$key"'" { print $NF }' "$file")" + # 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 + # containing the seperator (=), so using cut is much simpler + # and easier to understand. + value="$(awk -F= '$1 == "'"$key"'" { print $0 }' "$file" | cut -d'=' -f 2-)" if [[ -n $value ]] then -- cgit v1.1