aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2024-04-06 01:24:39 +0200
committerPatrick Spek <p.spek@tyil.nl>2024-04-06 01:24:39 +0200
commitef315f6777620d44a16bc48b3e602ba1725cf095 (patch)
treecddaeab06c74a4dc18802accf2e606b3dcfd2217
parent4d722c419a1e179683825e5815d8e2c4b35f5ed7 (diff)
Fix config_subkeys_for when dealing with reference variablesHEADmaster
-rw-r--r--CHANGELOG.md7
-rw-r--r--lib/util/config.bash3
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b11816..1680fac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [UNRELEASED]
+
+### Fixed
+
+- `config_subkeys` and `config_subkeys_for` should now leave off the `&` at the
+ end of a variable names which are references.
+
## [2.1.0] - 2024-04-02
### Added
diff --git a/lib/util/config.bash b/lib/util/config.bash
index 703dc4d..ff20bd0 100644
--- a/lib/util/config.bash
+++ b/lib/util/config.bash
@@ -138,6 +138,9 @@ config_subkeys_for() {
subkey="$(awk -F. '{ print $1 }' <<< "${result#"$key."}")"
+ # Remove trailing ampersand if it exists
+ [[ "${subkey: -1}" == "&" ]] && subkey="${subkey:0:-1}"
+
debug "bashtard/config_subkeys" "Found '$subkey' as subkey of '$key' through '$result'"
results+=("$subkey")
done < <(grep "^$key\." "$file" | awk -F= '{ print $1 }')