MIAOU-BASH is a collection of settings and helpers for leveraging BASH. Developer-friendly, it may be used as solo package with or without the miaou project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
643 B

#!/usr/bin/env miaou-bash
# declare -a normal
# declare -n ref1=normal
# ref1+=(5)
# ref1+=(9)
# ref1+=(10)
# declare -p normal
# declare -p ref1
# for i in "${ref1[@]}"; do echo "-> $i"; done
function build {
ref_name="$1"
[[ -v nested_count ]] && ((++nested_count)) || nested_count=1
nested_name="_nested_$nested_count"
declare -ga "$nested_name"=\(\)
declare -gn "$ref_name"="$nested_name"
}
function array_inspect {
declare -n ref="$1"
echo "array '$1' contains ${#ref[@]} elements"
for i in "${ref[@]}"; do echo "-> $i"; done
echo -----
}
build mine1
array_inspect mine1
mine1+=("A" "B C D" "E")
array_inspect mine1