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.
 
 

38 lines
666 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 sub {
[[ ! -v index ]] && index=0
declare -ga "$1"
declare -n ref2="$1"
ref2+=($((++index)))
ref2+=($((++index)))
}
function build {
array_name="$1"
sub "$array_name"
# declare -n ref=$array_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
build mine2
declare -n other=mine1
array_inspect other
array_inspect mine2