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