+ poor man's array copy

merge-requests/3/head
Dominika Liberda 2022-06-25 09:00:25 +02:00
parent c607722e2b
commit a954f330ab
1 changed files with 9 additions and 1 deletions

View File

@ -92,7 +92,15 @@ function nested_declare() {
# nested_add(ref, array)
function nested_add() {
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
ref+=("$nested_id")
}