+ poor man's array copy

This commit is contained in:
Dominika Liberda 2022-06-25 09:00:25 +02:00
parent c607722e2b
commit a954f330ab

View file

@ -92,7 +92,15 @@ function nested_declare() {
# nested_add(ref, array) # nested_add(ref, array)
function nested_add() { function nested_add() {
local nested_id=$(_nested_random) local nested_id=$(_nested_random)
declare -g -n _$nested_id=$2 declare -n nested_ref=$2
declare -g -A _$nested_id
# poor man's array copy
for i in ${!nested_ref[@]}; do
declare -g -A _$nested_id[$i]="${nested_ref[$i]}"
done
declare -p _$nested_id > /dev/stderr
local -n ref=$1 local -n ref=$1
ref+=("$nested_id") ref+=("$nested_id")
} }