From 8ee8b1aa5ab53bd1b567f845521007b6f02e331b Mon Sep 17 00:00:00 2001 From: pvincent Date: Sun, 19 Jul 2026 18:48:19 +0400 Subject: [PATCH] nested array 3 --- test/associative.test.bash | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/associative.test.bash b/test/associative.test.bash index cdd500e..be7123f 100755 --- a/test/associative.test.bash +++ b/test/associative.test.bash @@ -9,12 +9,15 @@ # declare -p ref1 # for i in "${ref1[@]}"; do echo "-> $i"; done -function build { +function array_new { ref_name="$1" + shift [[ -v nested_count ]] && ((++nested_count)) || nested_count=1 nested_name="_nested_$nested_count" - declare -ga "$nested_name"=\(\) + declare -ga "$nested_name" declare -gn "$ref_name"="$nested_name" + declare -n internal="$nested_name" + internal+=("$@") } function array_inspect { @@ -24,7 +27,7 @@ function array_inspect { echo ----- } -build mine1 +array_new mine1 'toto est fluo' 0 array_inspect mine1 -mine1+=("A" "B C D" "E") +mine1+=("B C D" "E") array_inspect mine1