[09/21] tests/lib.sh: Use namref to access an array

Message ID 20240520090611.10406-10-jonatan.schlag@ipfire.org
State New
Headers
Series [01/21] test: Add bash lib for colors |

Commit Message

Jonatan Schlag May 20, 2024, 9:05 a.m. UTC
  ! does not work here. So the solution here is:
https://unix.stackexchange.com/questions/60584/how-to-use-a-variable-as-part-of-an-array-name/60585#60585

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 tests/lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/tests/lib.sh b/tests/lib.sh
index 006862da6..ad7c12cb0 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -28,7 +28,7 @@  var_has_value() {
 }
 
 test_that_key_in_arry_has_value() {
-	local array="${!1}"
+	local -n array="${1}"
 	local arrayname="${1}"
 	local key="${2}"
 	local value="${3}"